<?xml version="1.0" encoding="utf-8"?>
<!--
                                                                                     
 h       t     t                ::       /     /                     t             / 
 h       t     t                ::      //    //                     t            // 
 h     ttttt ttttt ppppp sssss         //    //  y   y       sssss ttttt         //  
 hhhh    t     t   p   p s            //    //   y   y       s       t          //   
 h  hh   t     t   ppppp sssss       //    //    yyyyy       sssss   t         //    
 h   h   t     t   p         s  ::   /     /         y  ..       s   t    ..   /     
 h   h   t     t   p     sssss  ::   /     /     yyyyy  ..   sssss   t    ..   /     
                                                                                     
	<https://y.st./>
	Copyright © 2017 Alex Yst <mailto:copyright@y.st>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <https://www.gnu.org./licenses/>.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="https://y.st./en/coursework/CS1101/" />
		<title>Leaning Journal &lt;https://y.st./en/coursework/CS1101/&gt;</title>
		<link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
		<link rel="stylesheet" type="text/css" href="/link/basic.css" />
		<link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
		<script type="text/javascript" src="/script/javascript.js" />
		<meta name="viewport" content="width=device-width" />
	</head>
	<body>
		<nav>
			<p>
				<a href="/en/">Home</a> |
				<a href="/en/a/about.xhtml">About</a> |
				<a href="/en/a/contact.xhtml">Contact</a> |
				<a href="/a/canary.txt">Canary</a> |
				<a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
				<a href="/en/opinion/">Opinions</a> |
				<a href="/en/coursework/">Coursework</a> |
				<a href="/en/law/">Law</a> |
				<a href="/en/a/links.xhtml">Links</a> |
				<a href="/en/coursework/CS1101/index.xhtml.asc">{this page}.asc</a>
			</p>
			<hr/>
			<p>
				<a href="/en/coursework/BUS1101/" title="Principles of Business Management">BUS 1101</a> |
				<span class="hyperlink_unavailable" title="Basic Accounting">BUS 1102</span> |
				<span class="hyperlink_unavailable" title="Principles of Marketing">BUS 2201</span> |
				<span class="hyperlink_unavailable" title="Multinational Management">BUS 2207</span> |
				<span class="hyperlink_unavailable" title="Business and Society">BUS 3306</span> |
				<a href="/en/coursework/CS1101/" title="Programming Fundamentals">CS 1101</a> |
				<a href="/en/coursework/CS1102/" title="Programming 1">CS 1102</a> |
				<a href="/en/coursework/CS1103/" title="Programming 2">CS 1103</a> |
				<span class="hyperlink_unavailable" title="Computer Systems">CS 1104</span> |
				<a href="/en/coursework/CS2203/" title="Databases 1">CS 2203</a> |
				<span class="hyperlink_unavailable" title="Communications and Networking">CS 2204</span> |
				<a href="/en/coursework/CS2205/" title="Web Programming 1">CS 2205</a> |
				<a href="/en/coursework/CS2301/" title="Operating Systems 1">CS 2301</a> |
				<span class="hyperlink_unavailable" title="Software Engineering 1">CS 2401</span> |
				<span class="hyperlink_unavailable" title="Data Structures">CS 3303</span> |
				<span class="hyperlink_unavailable" title="Analysis of Algorithms">CS 3304</span> |
				<span class="hyperlink_unavailable" title="Web Programming 2">CS 3305</span> |
				<span class="hyperlink_unavailable" title="Databases 2">CS 3306</span> |
				<span class="hyperlink_unavailable" title="Operating Systems 2">CS 3307</span> |
				<span class="hyperlink_unavailable" title="Information Retrieval">CS 3308</span> |
				<span class="hyperlink_unavailable" title="Comparative Programming Languages">CS 4402</span> |
				<span class="hyperlink_unavailable" title="Software Engineering 2">CS 4403</span> |
				<span class="hyperlink_unavailable" title="Advanced Networking and Data Security">CS 4404</span> |
				<span class="hyperlink_unavailable" title="Mobile Applications">CS 4405</span> |
				<span class="hyperlink_unavailable" title="Computer Graphics">CS 4406</span> |
				<span class="hyperlink_unavailable" title="Data Mining and Machine Learning">CS 4407</span> |
				<span class="hyperlink_unavailable" title="Artificial Intelligence">CS 4408</span> |
				<span class="hyperlink_unavailable" title="English Composition 2">ENGL 1102</span> |
				<span class="hyperlink_unavailable" title="World Literature">ENGL 1405</span> |
				<span class="hyperlink_unavailable" title="Introduction to Environmental Science">ENVS 1301</span> |
				<a href="/en/coursework/HIST1421/" title="Greek and Roman Civilization">HIST 1421</a> |
				<span class="hyperlink_unavailable" title="College Algebra">MATH 1201</span> |
				<span class="hyperlink_unavailable" title="Calculus">MATH 1211</span> |
				<span class="hyperlink_unavailable" title="Introduction to Statistics">MATH 1280</span> |
				<span class="hyperlink_unavailable" title="Discrete Mathematics">MATH 1302</span> |
				<span class="hyperlink_unavailable" title="Introduction to Philosophy">PHIL 1402</span> |
				<a href="/en/coursework/PHIL1404/" title="Ethics and Social Responsibility">PHIL 1404</a> |
				<a href="/en/coursework/POLS1503/" title="Globalization">POLS 1503</a> |
				<span class="hyperlink_unavailable" title="Introduction to Psychology">PSYC 1504</span> |
				<a href="/en/coursework/UNIV1001/" title="Online Education Strategies">UNIV 1001</a>
			</p>
			<hr/>
			<p>
				<a href="/en/coursework/CS1101/t_area.py.xhtml" title="t_area.py">Unit 2</a> |
				<a href="/en/coursework/CS1101/calculator_flowchart.xhtml" title="calculator flowchart">Unit 3</a> |
				<a href="/en/coursework/CS1101/tryme3.py.xhtml" title="tryme3.py">Unit 4</a> |
				<a href="/en/coursework/CS1101/mycalc.py.xhtml" title="mycalc.py">Unit 5</a> |
				<a href="/en/coursework/CS1101/bool.py.xhtml" title="bool.py">Unit 6</a> |
				<a href="/en/coursework/CS1101/sort_fruits.py.xhtml" title="sort_fruits.py">Unit 7</a>
			</p>
			<hr/>
		</nav>
		<header>
			<h1>Leaning Journal</h1>
			<p>CS 1101: Programming Fundamentals</p>
		</header>
<h2 id="Unit1">Unit 1</h2>
<p>
	First, I read through the learning guide, making a list of what I&apos;d need to read this week.
	One of the textbooks for this course is under the nonfree <abbr title="GNU &quot;Free&quot; Documentation License">GFDL</abbr>.
	At some point, I&apos;ll write up an essay on exactly whey I consider this to be a nonfree license even when no invariant sections and no cover texts are used, but today, that essay is only partially complete and hasn&apos;t been released.
	The version of that textbook that can be linked to without the reader having a University of the People account is also behind a CloudFlare <abbr title="Completely Automated Public Turing test to tell Computers and Humans Apart">CAPTCHA</abbr> wall, which is always aggravating.
	This isn&apos;t the school&apos;s fault, but CloudFlare really loves maliciously discriminating against us <abbr title="The Onion Router">Tor</abbr> users.
	Due to CloudFlare&apos;s high popularity, the CloudFlare <abbr title="Completely Automated Public Turing test to tell Computers and Humans Apart">CAPTCHA</abbr> walls are common and get very old very quickly.
	The other textbook appears to not have a license at all, making it also nonfree.
	The textbooks are as follows:
</p>
<ul>
	<li>
		<a href="http://epe.lac-bac.gc.ca./003/008/099/003008-disclaimer.html?orig=/100/200/300/allan_publishing/history_personal_computer/index.html">Disclaimer - Electronic Collection</a>
	</li>
	<li>
		<a href="http://interactivepython.org/runestone/static/thinkcspy/index.html">Attention Required! | Cloudflare</a>
	</li>
</ul>
<p>
	In addition to some sections from the course textbooks, we also need to read these three pages:
</p>
<ul>
	<li>
		<a href="https://thocp.net/software/software_reference/introduction_to_software_history.htm">Introduction to Software History</a>
	</li>
	<li>
		<a href="http://computernostalgia.net./articles/HistoryofProgrammingLanguages.htm">History of Programming Languages, computer languages, software, applications</a>
	</li>
	<li>
		<a href="http://www.randomhistory.com./2008/06/26_software.html">A History of Software</a>
	</li>
</ul>
<p>
	One of the tasks for the week is to install Python on our machines.
	I&apos;ve already got that installed though, so that&apos;s one less task to worry about.
	I think that Python might come pre-installed on Debian systems.
	Even if it didn&apos;t though, installing it would have been super simple.
	Running <code>sudo aptitude install python</code> would have done the trick.
</p>
<p>
	I started by reading the non-textbook reading assignments first, taking notes in my <a href="https://y.st./en/coursework/CS1101/#Unit1">learning journal entry</a> as interesting facts came up.
	It seems that <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> (my native language) and Python (the language used in this course) were both invented at around the same time; 1994 and 1990, respectively.
	Recursive functions were first implemented in Algol.
	I would have thought that recursive functions would be definable in any language that supports named functions, but it seems that this isn&apos;t the case.
	Switch statements (known as &quot;case statements&quot; in Pascal) were first introduced in Pascal.
	C++ was ont of the first object-oriented programming languages.
	I&apos;m told that C++ is a mess of a language, and that developers should stick with C instead, but the concept of object-oriented programming is one that persists in a more clean form in other modern programing languages.
	As examples, modern <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> is partially object-oriented, while Python is completely object-oriented.
	The reading assignment says that Java is a textbook example of a good language, but I very much disagree.
	Java has a concept that it calls &quot;overloading&quot;.
	The premise is that multiple functions (methods) can share the same name, and the program decides which function is meant by a particular function call based on the types of the values passed in as arguments.
	This makes debugging a huge pain.
	For example, if you mistakingly pass the wrong variable into a method call or the variable that you pass in isn&apos;t the type that you think it is, the compiler often complains that the function that you tried to call doesn&apos;t exist.
	At that point, you try to figure out why your function definition is being ignored and/or try to find a typo in either the method name in the method call or the method name in the method definition.
	Having the ability to give multiple functions (methods) the same name is stupid, and even if you don&apos;t make use of that feature, it causes issues when trying to figure out why your program won&apos;t compile.
	It seems that C was the first portable language.
	That&apos;s kind of interesting, seeing as C is still in wide use today.
	Portability is no doubt vital, but it looks like improving upon this first portable language isn&apos;t an easy task; C is still a great language, even today, so it must have been fantastic for its time when first developed.
	The text also mentions &quot;<abbr title="Uniform Resource Locator">URL</abbr>s&quot;, but that term is a bit outdated.
	The correct term these days is &quot;<abbr title="Uniform Resource Identifier">URI</abbr>s&quot;.
</p>
<p>
	It took me time to get back to my coursework because life is pretty hectic for me right now, but I eventually got back on task and read the assigned sections from the text book.
	I misread something near the beginning of the book: I thought that it was calling C++ a low-level language, but saying that programs written in low-level languages cannot be made to run on multiple types of machines without rewriting them for each type of machine.
	I happen to know of a game that I used to play though, a cross-platform game written in C++.
	The book actually was calling C and C++ high-level languages though, so it&apos;s all good.
	I consider C and C++ to be low-level languages myself, but the thing is, high to low is a range.
	C is a higher-level language than, say, assembly code, but it&apos;s lower than <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> and Python.
	The book does make a mistake in regards to interpreted languages though.
	It says that the interpreter processes the script a little at a time, alternating between reading the script and performing actions.
	This isn&apos;t always true.
	<abbr title="PHP: Hypertext Preprocessor">PHP</abbr>, for example, reads and interprets the <strong>*entire script*</strong> before performing even a <strong>*single*</strong> action.
	The <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> interpretor &quot;compiles&quot; all of the code in the beginning, but there&apos;s no compiled executable, making it an interpreted language, not a compiled language.
	Because of this, if there is a syntax error anywhere in the script, the script will fail to execute before anything happens.
	It&apos;s important to note the difference between syntax errors and runtime errors though, as a script with runtime errors can and will function up to the point in which the error occurs.
	Bash, on the other hand, does as the book describes.
	It reads the script line by line, interpreting each line as a command and executing it before moving on to the next line.
	I&apos;m not sure what Python does.
	While I&apos;m fluent in Python, it&apos;s not a language that I use often enough to remember the details of how syntax errors are treated.
	The book also says that Linus Torvalds invented Linux, the operating system, and that this operating system evolved out of a simple program that they wrote.
	This is untrue.
	The Linux operating system evolved out of the <abbr title="GNU&apos;s Not Unix">GNU</abbr> project&apos;s operating system.
	The Linux operating system contains the Linux kernel, and it&apos;s the Linux kernel that Torvalds wrote and that evolved from Torvalds&apos; simple program.
	The part of the reading that mentions that people treat computers as people is kind of funny.
	I consider my Debian machine to be sort of like a good friend.
	I&apos;m often lost without it, and it almost never fails me.
	One of my parents though constantly complains about their computer.
	They think that all computers are stupid, just because they&apos;re running an operating system that&apos;s known to be a major pain to work with.
	They refuse to upgrade to something better though, something that would help them see their computer as an comrade as well.
</p>
<p>
	Next, I wrote up my initial discussion post.
	With how late my initial post was, I was very lucky that someone responded to it at all.
	To be honest, I was worried.
	The coming week should be less hectic than this week, so I should be able to get my discussion post in sooner next time.
	It seems that I made one fellow classmate think that I&apos;m involved with a free software project.
	Perhaps the wording of my post was bad.
	Technically, I am the sole developer of the <a href="https://notabug.org./y.st./include.d/releases">include.d</a> library and some lesser projects that depend on it, but I hardly ever have time to work on them these days lately.
	Furthermore, these projects are important to no one but myself.
	I&apos;m not some highly-known developer making a difference in the world, I&apos;m just a simple computer user that avoids using proprietary software and media.
	The other person that responded to me bought up the great example of office suites.
	Should they be written in a compiled language or an interpreted language?
	It seems like both have advantages and trade-offs.
	In fact, LibreOffice is written in C++, a compiled language, as well as Python, an interpreted language.
	It also contains Java components.
	Java&apos;s strange.
	You can&apos;t call it a compiled language, because you can&apos;t compile Java into something that will run without an interpreter, but at the same time, you can&apos;t call it an scripted (interpreted) language, because it can&apos;t run uncompiled scripts.
	You must compile the source code into Java byte code, then run it in the Java interpreter.
	From one the students that I replied to, I learned something that I didn&apos;t know before.
	Cobol can&apos;t be used to write system software, only applications.
	This means that Cobol is either not a complete language or it&apos;s a domain-specific language.
	I assume that if it can&apos;t be used to create system software, it&apos;s because of some limitation such as an inability to create software without a <abbr title="graphical user interface">GUI</abbr>.
	In any case, it&apos;s not useful as a general-purpose language and shouldn&apos;t be used as such.
	Still, I find this surprising.
	It&apos;s true that I&apos;ve never tried to learn Cobol, but I hear it mentioned on a semi-regular basis.
	I thought that it was one of the more popular of the older languages still in use (not super-popular like C, but not really a fringe language either), which would imply that it&apos;s a useful language.
	I don&apos;t have time this week, but I&apos;ll have to look into Cobol more in the future to find out how it works.
</p>
<p>
	Finally, with everything else completed, I took the ungraded quiz.
	At first, I was a bit annoyed that we&apos;re being quizzed on history instead of learning actual programming.
	Which programming language wasn&apos;t developed in the 1950s?
	In what school was C developed?
	That information is useless.
	But then came the question about the origin of the term &quot;bug&quot;.
	I&apos;m almost certain that that wasn&apos;t even discussed in the reading material.
	In fact, as I&apos;ve heard the story before, I was quite surprised that it wasn&apos;t!
	If we&apos;re going to be quizzed on things not covered by the text, how do we stand a chance of success?
	We have no way to know what random facts we&apos;re going to need to know for the quizzes, so research on our own is of no use against this problem, as we have no way to know what to research.
	I really hope that I just missed the part about the moth, because then it would at least be my own fault, not something unavoidable.
	The history components of this course are going to be a major challenge for me.
	I learned to program before taking any programming courses, and since then, have taken a few.
	Because of that, I don&apos;t think that the code work in this introductory course will be a problem.
	It doesn&apos;t hurt either that the programming to be done in this course is to be done in Python.
	Python isn&apos;t my favorite language or anything, but there&apos;s no denying that it&apos;s one of the easier languages to work with.
	I&apos;m bad at history though.
	I&apos;m bad at remembering useless trivia, such as names and dates.
</p>
<p>
	I&apos;m not sure how to answer the posed question of what skills I&apos;m gaining so far.
	We haven&apos;t even begun to touch code yet!
	At the moment, we&apos;re still covering the basics.
	I suppose that I am learning to think more deeply about what language to use when.
	Compiled and scripted languages both have their places, a fact that I already knew, but the line between when each is better can be a bit blurry.
	As for what I&apos;m learning about myself as a learner, I&apos;m not sure that I&apos;ve picked something new about that up from the course yet, as like I&apos;ve said, we&apos;ve not really begun.
	However, I have found because of my hectic schedule right now that I don&apos;t really do well in my studies when my time and energy are stretched to the max.
	This week has been horridly stressful, and I feel like it&apos;s taken a toll on my coursework.
	In my other course, I ended up having to write most of an <a href="https://y.st./en/coursework/PHIL1404/Apple_and_ethics.xhtml">essay</a> in a single day because I hadn&apos;t had the time to get to it until then.
	I hit about four times the minimum word count, as I always put in a good effort, but I can&apos;t help but feel like I would have been able to polish the essay more had I had more free time and more free energy.
	In this course, I had to submit my main discussion post with only just over a day left on the clock, which was frustrating.
	Again, I would have loved to have had the time and energy to put more into that than I did.
	My most important thought in closing is probably that I hope next week will go more smoothly and that I wish I had had the time to do better on my assignments this week, including this one.
</p>
<h3>Exercises:</h3>
<h4>Exercise 1.1</h4>
<p>
	I am &lt;=&gt; CS 1101 online at [+].
	<em>(I tried to get fancy and use characters from outside the English language in that sentence, but the University of the People submission form choked on those characters.)</em>
</p>
<p>
	I University of the People taking am CS 1101 at online.
</p>
<h4>Exercise 1.3</h4>
<blockquote>
<pre>yst@newdawn.hn.y.st.:~$ <code>python</code>
Python 2.7.9 (default, Jun 29 2016, 13:08:31) 
[GCC 4.9.2] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; <code>help()</code>

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type &quot;quit&quot;.

To get a list of available modules, keywords, or topics, type &quot;modules&quot;,
&quot;keywords&quot;, or &quot;topics&quot;.  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as &quot;spam&quot;, type &quot;modules spam&quot;.

help&gt; <code>quit</code>

You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type &quot;help(object)&quot;.  Executing &quot;help(&apos;string&apos;)&quot;
has the same effect as typing a particular string at the help&gt; prompt.
&gt;&gt;&gt; <code>help(print)</code>
  File &quot;&lt;stdin&gt;&quot;, line 1
    help(print)
             ^
SyntaxError: invalid syntax
&gt;&gt;&gt; <code>help(&apos;print&apos;)</code>

&gt;&gt;&gt; <code>quit</code>
Use quit() or Ctrl-D (i.e. EOF) to exit
&gt;&gt;&gt; <code>quit()</code>
yst@newdawn.hn.y.st.:~$ </pre>
</blockquote>
<h4>Exercise 1.4</h4>
<blockquote>
<pre>yst@newdawn.hn.y.st.:~$ <code>python</code>
Python 2.7.9 (default, Jun 29 2016, 13:08:31) 
[GCC 4.9.2] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; print <code>4.35/1.61</code>
2.70186335404
&gt;&gt;&gt; <code>quit()</code>
yst@newdawn.hn.y.st.:~$ </pre>
</blockquote>
<h3>Discussion board post drafts</h3>
<p>
	I&apos;m not sure why, but the learning journal assignment instructions this week say to draft the discussion posts here in the learning journal.
	So, these were the posts I made.
	Typically, I would have drafted them in my main journal, instead of my learning journal.
	Either option allows me to compose my entries in <abbr title="Extensible Hypertext Markup Language">XHTML</abbr> though, which gives me much more control over the formatting while at the same time allowing me to ignore irrelevant details such as text size and font.
</p>
<blockquote>
	<p>
		Comparing all of the advantages of a specific compiled language and a specific interpreted language doesn&apos;t seem to present any useful information about the differenced between compiled and interpreted languages.
		For example, comparing the C programming language to Python shows us that Python is easier to work with.
		Python is a higher-level language than C, so Python takes care of all the little things automatically that C requires that you do manually.
		That said, C has the advantage of being more efficient in terms of resource usage, both because it&apos;s compiled and because it&apos;s a lower-level language.
		In both cases, the differences are because of the level of the language, not how whether the language is compiled or interpreted.
	</p>
	<p>
		It might be more useful to discuss compiled languages in general versus interpreted languages in general.
		Compiled languages are more efficient than interpreted languages because the machine only has to compile the code once.
		On the inside, the interpreter is basically compiling the script <strong>*every time that you run it*</strong>.
		That&apos;s a lot of extra compiling, if you run the script often!
		On the other hand, interpreted languages offer the flexibility of easier modification.
		If you&apos;re a part of the free software world like I am, having the source code and the executable be the same thing just makes sense.
		There&apos;s a problem though: interpreted languages require, well, an interpreter.
		This interpretor could be written in an interpreted language itself, but then you&apos;d need an interpretor for the interpretor!
		It&apos;s turtles all the way down, if you try to do it that way.
		Instead, the interpretor itself is a great example of a program that should be written in a compiled language, so it can be built into a binary executable that the computer can figure out how to use without needing another interpretor.
		Anything that requires a high level of efficiency, such as a kernel or other well-used system component, should also be written in a compiled language.
		Interpreted languages are good for almost everything else.
		The more simple and less vital the software, the more you should consider using an interpreted language.
		Are you trying to write code to automate a task?
		Use an interpreted language.
		Are you writing a game?
		An interpreted language is a good idea.
		Are you writing code for your website?
		Unless the website sees <strong>*very*</strong> heavy traffic (think Wikipedia), an interpreted language is probably your best bet.
		Anything that you&apos;re going to have to modify frequently should also be written in an interpreted language.
	</p>
</blockquote>
<blockquote>
	<p>
		When I said that I&apos;m a part of the free software world, I didn&apos;t mean that I&apos;m involved with a specific project.
		I&apos;ve written a couple bug patches for the game Minetest, but other than that, I&apos;m a free software <strong>*user*</strong>.
		I don&apos;t run any proprietary software whatsoever.
		I also only buy free music, music under a <abbr title="Creative Commons Attribution">CC BY</abbr> or <abbr title="Creative Commons Attribution-ShareAlike">CC BY-SA</abbr> license.
	</p>
	<p>
		I am working on a library of classes, functions, and constants for <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> called <a href="https://notabug.org./y.st./include.d/releases">include.d</a>, but that&apos;s mainly for my personal uses and likely isn&apos;t valuable to others.
		It&apos;s still under the <abbr title="GNU&apos;s Not Unix">GNU</abbr> $[GPL], but I haven&apos;t had time as of late to work on it much because life has been hectic.
		I&apos;m in the middle of a move to a new house (carrying all my stuff on foot, I don&apos;t drive), school, and work ...
		My code likely won&apos;t be updated for quite a while.
		My current goal with include.d though is to add scheme-specific <abbr title="Uniform Resource Identifier">URI</abbr> parsers so I can get back to building my <a href="https://notabug.org./y.st./OnionSpider">darknet spider</a> that needs them.
		The spider is almost certainly in a broken state right now though because of updates to include.d, so I don&apos;t recommend trying to run it until I finish updating include.d again and rework the spider to use the new version.
		I also release my <a href="https://y.st./">website</a> and all its content under the <abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="General Public License">GPL</abbr>.
	</p>
</blockquote>
<blockquote>
	<p>
		I can&apos;t say for sure about if the Microsoft Office developers could make Microsoft Office work well in an interpreted language, as I&apos;m not convinced that it works well now.
		It&apos;s a bloated office suite in need of a serious tune-up and I don&apos;t think that the developers have what it takes to fix that, no matter the language.
		In general though, I think that other office suites could be written to run well in an interpreted language.
		Office suites are more complex than other pieces of software (needlessly complex, at least in the case of word processing), so it might be better to write those in a compiled language after all.
		LibreOffice, for example, is written in a combination of C++, Java, and Python.
		I don&apos;t claim to know what parts are written in what language, but I imagine that the base components that need to run quickly are written in C++ while the less vital components, such as the user interface and some of the more complex functionality, are written in Java and Python.
		Depending on the game, you might be better off in a compiled or interpreted language, even.
		Simpler games such as two-dimensional platformers would be better off in an in interpreted language, while resource-intensive games would be better off in a compiled language.
		In part, it&apos;s a trade-off between making the code easier to write and maintain or making the code easier for the machine to handle.
		The more complex the task, the more machine-optimization will need to happen to keep the software from taking too many of the machine&apos;s resources.
		When the task is simpler though, there&apos;s lots of wiggle room, so you can put more of the burden on the machine and less on the human.
	</p>
</blockquote>
<blockquote>
	<p>
		C is a great language to compare to Python.
		Not only is C pretty much the de facto main compiled language, it&apos;s also the language than many interpreters (and I think compilers) are written in!
		The Python interpreter is one such C-based interpreter.
		Even when you&apos;re not using C directly, you&apos;re still probably using C.
	</p>
	<p>
		I think that C&apos;s strength, relying on libraries to do the machine-specific lifting and having a platform-independent interface is one of the major strengths of Python as well.
		Instead of a machine-specific library though, Python has a machine-specific version of the interpretor, compiled from the same source code.
		Just like with C, the code can be written once and still run on multiple processors and multiple systems.
	</p>
</blockquote>
<blockquote>
	<p>
		You say that Cobol cannot be used to write system software; it can only be used for writing application software.
		Would you consider this weakness to be particularly detrimental?
		It means that Cobol can&apos;t handle certain functionalities that one might need to write into their code.
		At the same time though, removing unneeded features sometimes makes the language more efficient for its intended use.
		Would you consider Cobol to simply be a domain-specific language, good at what it&apos;s designed to do, or a handicapped language, unable to perform certain simple tasks?
	</p>
</blockquote>
<blockquote>
	<p>
		I&apos;d also argue that debugging Java is a pain in the neck to do.
		That disadvantage alone is the reason that I don&apos;t write much in Java.
		If I can ever get my Android development environment to function though, I might suck it up and start using Java for mobile application development.
		There are several applications that I&apos;d love to write, as I don&apos;t see the applications that I need available elsewhere yet.
	</p>
	<p>
		As for C#, I agree with you that it offers little portability.
		Attempts are being made to make C# code run on non-Windows platforms, but I&apos;m told that they&apos;re incomplete at best.
		I don&apos;t recommend that anyone use C# for writing software, as it binds your code to only work on one platform; and not even a very good platform at that.
	</p>
	<p>
		How would you compare these two languages to Python?
	</p>
</blockquote>
<h2 id="Unit2">Unit 2</h2>
<p>
	I began the week by looking over the assignments as I often do.
	First off, I checked the <a href="https://y.st./en/coursework/CS1101/#Unit2">learning journal</a> assignment so that I&apos;d know if it was anything like <a href="https://y.st./en/coursework/CS1101/#Unit1">last week&apos;s</a>.
	That would tell me not only where I should take my notes for the week, but also the level of detail my notes should have.
	When not taking notes on my activities in my learning journal, I instead take them in my main journal.
	Sure enough, the learning journal assignment for this week is the same as last week&apos;s.
	Next, I checked the programming assignment for the week, the first in the course.
	Strangely, it specifies that a Microsoft Word document must be handed in.
	In general, University of the People accepts both the Microsoft Office formats and the OpenOffice.org/LibreOffice formats.
	It doesn&apos;t bother me at all, as LibreOffice makes the conversion simple, but it does make this assignment seem ... out of place.
	Additionally, word processing documents of any format seem like a bad fit for this assignment.
	The options are to take a screenshot of the output or to copy and paste the text of the output.
	In case of screenshots, word-processing documents are a horrid fit.
	A bare image file would be easier to work with and easier to read on the receiving end.
	In case of pasted text, a word-processing document would be less bad, but a plain text file would still be clearly a better option.
	The assignment was too easy to put off though, so I set to work on that right away.
</p>
<p>
	First, I learned that the Python prompt is not <abbr title="Integrated Development and Learning Environment">IDLE</abbr>.
	The assignment specifically requests that I use <abbr title="Integrated Development and Learning Environment">IDLE</abbr>.
	I was supposed to install Python and <abbr title="Integrated Development and Learning Environment">IDLE</abbr> last week, but I misunderstood and thought that <abbr title="Integrated Development and Learning Environment">IDLE</abbr> was a part of Python.
	It isn&apos;t.
	Running <code>sudo aptitude install idle</code> on the command line rectified the issue though.
</p>
<p>
	<abbr title="Integrated Development and Learning Environment">IDLE</abbr>&apos;s combination of being a shell and being a text editor is strange.
	It also has an annoying habit of adding sequences of space characters instead of singular tab characters when I hit the tab key.
	There doesn&apos;t seem to be any way to override this obnoxious behavior either, though the number of spaces that <abbr title="Integrated Development and Learning Environment">IDLE</abbr> uses can be configured.
	In an attempt to work around the problem, I kept a tab character on my clipboard and pasted it as needed, but it&apos;s an ugly solution and I would have expected better from <abbr title="Integrated Development and Learning Environment">IDLE</abbr>.
	That said, we didn&apos;t actually need any indention in this assignment, so that was a small, wasted effort.
	Additionally, there doesn&apos;t seem to be an option to visualize whitespace.
	Again, I expect more out of my text editors.
	As for my actual <a href="https://y.st./en/coursework/CS1101/t_area.py.xhtml">script</a>, it contains more comments than code.
</p>
<p>
	The reading assignment for the week is a few chapters from our assigned textbooks in addition to a couple of videos:
</p>
<ul>
	<li>
		<a href="https://www.youtube.com./watch?v=husPzLE6sZc">Introduction to Programs Data Types and Variables - YouTube</a>
	</li>
	<li>
		<a href="https://www.youtube.com./watch?v=iZAtkS0F-Zo">Fun with Strings - YouTube</a>
	</li>
</ul>
<p>
	The first video reminded me of Python&apos;s obnoxious habit of adding a new line character after everything that you tell it to <code>print</code>.
	For new users, this might be helpful.
	For experienced users, this makes things more difficult.
	We know to add <code>\n</code> when we need a new line.
	So what do we do when we <strong>*don&apos;t*</strong> need a new line in Python?
	Well, there&apos;s the option of adding a comma after the thing to print, which prevents Python from outputting a new line, but it causes it to output a space instead.
	What if we need Python to output only and exactly what we tell it to?
	Well, the short answer is that it&apos;s not possible.
	The longer answer is that in most cases, you can use concatenation to achieve your desired result, but you still can&apos;t get Python to output only and exactly what you tell it to.
</p>
<p>
	The book says that <code>//</code> is used for floor division instead of <code>/</code>.
	The book must be working with Python3 then, not Python2.
	After seeing that, I started using Python3 for the exercises instead of my system&apos;s default, Python 2.
	In the next Debian release, Python3 will likely be the default.
</p>
<p>
	With everything done for the week, I looked over my code assignment one last time, then submitted it.
	I considered adding <code>#!/usr/bin/python3</code> to the top of the script, but I don&apos;t know who will be grading it.
	If they&apos;re not on the same operating system as I am, which is highly likely, they won&apos;t have Python installed in the same place.
	That line might make the script fail to execute if Python is instead installed elsewhere.
	I tried to take the ungraded quiz, but I was too late.
	I thought that the ungraded quizzes stayed open until the end of the term, but I either remembered incorrectly, or the quizzes are set up differently this term than last.
	It&apos;s been a hectic week due to non-university events, such the move that I&apos;m in the middle of, so I thought that I&apos;d take a little bit of a break before taking the quiz.
	Bad idea.
	If I&apos;m to get a chance to test my knowledge with the quizzes, I have to do it right away.
</p>
<p>
	My final thought for the week is that I must push forward.
	There&apos;s no time for rest until everything, both graded and ungraded, is done.
</p>
<h3>Exercises:</h3>
<h4>Exercise 2.1</h4>
<blockquote>
<pre>yst@newdawn.hn.y.st.:~$ <code>python</code>
Python 2.7.9 (default, Jun 29 2016, 13:08:31) 
[GCC 4.9.2] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; <code>m = 1,000,000</code>
&gt;&gt;&gt; <code>type(m)</code>
&lt;type &apos;tuple&apos;&gt;
&gt;&gt;&gt; <code>exit()</code>
yst@newdawn.hn.y.st.:~$ </pre>
</blockquote>
<h4>Exercise 2.2</h4>
<blockquote>
<pre>yst@newdawn.hn.y.st.:~$ <code>python3</code>
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; <code>5</code>
5
&gt;&gt;&gt; x = <code>5</code>
&gt;&gt;&gt; x + <code>1</code>
6
&gt;&gt;&gt; <code>exit()</code>
yst@newdawn.hn.y.st.:~$ </pre>
</blockquote>
<h3>Exercise 2.3</h3>
<blockquote>
<pre>yst@newdawn.hn.y.st.:~$ <code>python3</code>
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; <code>width = 17</code>
&gt;&gt;&gt; <code>height = 12.0</code>
&gt;&gt;&gt; <code>delimiter = &apos;.&apos;</code>
&gt;&gt;&gt; <code>p0 = width/2</code>
&gt;&gt;&gt; <code>print(p0, type(p0))</code>
8.5 &lt;class &apos;float&apos;&gt;
&gt;&gt;&gt; <code>p1 = width/2.0</code>
&gt;&gt;&gt; <code>print(p1, type(p1))</code>
8.5 &lt;class &apos;float&apos;&gt;
&gt;&gt;&gt; <code>p2 = height/3</code>
&gt;&gt;&gt; <code>print(p2, type(p2))</code>
4.0 &lt;class &apos;float&apos;&gt;
&gt;&gt;&gt; <code>p3 = 1 + 2 * 5</code>
&gt;&gt;&gt; <code>print(p3, type(p3))</code>
11 &lt;class &apos;int&apos;&gt;
&gt;&gt;&gt; <code>p4 = delimiter * 5</code>
&gt;&gt;&gt; <code>print(p4, type(p4))</code>
..... &lt;class &apos;str&apos;&gt;
&gt;&gt;&gt; <code>exit()</code>
yst@newdawn.hn.y.st.:~$</pre>
</blockquote>
<h4>Exercise 2.4</h4>
<blockquote>
<pre>yst@newdawn.hn.y.st.:~$ <code>python3</code>
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; <code>pi = 3.1415926535897931</code>
&gt;&gt;&gt; <code>print((4/3) * pi * 5**3)</code>
523.5987755982989
&gt;&gt;&gt; <code>print((24.95 * 0.6 + 0.75) * 60 + 2.25)</code>
945.4499999999999
&gt;&gt;&gt; <code>print(6.87 + 2 * 8.25 + 3 * 7.2)</code>
44.97
&gt;&gt;&gt; <code>exit()</code>
yst@newdawn.hn.y.st.:~$</pre>
</blockquote>
<h2 id="Unit3">Unit 3</h2>
<p>
	One of the first things that I saw this week was a link at the bottom of the classroom index page that read:
</p>
<blockquote>
	<p>
		Dia - Download Windows version of Dia diagram tool for flowcharts
	</p>
</blockquote>
<p>
	Admittedly, I panicked a bit.
	Did we need this windows-specific software to complete this week&apos;s assignment?
	Would I be able to complete this week&apos;s assignment, or would I have to automatically fail by not being able to use the software?
	Thankfully, the link was just poorly-phrased and falsely assumed that all students are running Windows.
	The tool is also available for other systems and is even <a href="apt:dia">available in the Debian repository</a>.
	Running <code>sudo aptitude install dia</code> will install it without any hassle.
</p>
<p>
	Unfortunately, due to life circumstances, I wasn&apos;t able to get right on my coursework as I&apos;d like to have.
	I keep thinking that each next week will be better, but so far, it hasn&apos;t been that way.
	Lack of time has been my biggest challenge for the week, as I continue to move my stuff from my old house to my new apartment on foot (a half-hour walk when unburdened), go to work, attend school, try to clean up my old house for sale, debug my malfunctioning mobile device, and more.
</p>
<p>
	In addition to a few chapters of the textbook, the reading list for the week was as follows:
</p>
<ul>
	<li>
		<a href="https://users.evtek.fi/~jaanah/IntroC/DBeech/3gl_flow.htm">Designing programs with flow charts</a>
	</li>
	<li>
		<a href="https://users.evtek.fi/~jaanah/IntroC/DBeech/3gl_pseudo.htm">3GL Program Design - Pseudocode</a>
	</li>
	<li>
		<a href="https://www.youtube.com./watch?v=DRwtJ1WjzI8">Flowcharting - Part 1 - YouTube</a>
	</li>
	<li>
		<a href="https://www.youtube.com./watch?v=Rg-fO7rDsds">What Is Pseudocode? - YouTube</a>
	</li>
	<li>
		<a href="https://www.youtube.com./watch?v=UNWF6eBErWs">Flowcharting - Part 2 - YouTube</a>
	</li>
	<li>
		<a href="https://www.youtube.com./watch?v=hN9xemJYwos">Problem Solving Techniques #8: Flow Charts - YouTube</a>
	</li>
	<li>
		<a href="http://faculty.ccri.edu./mkelly/COMI1150/PseudocodeBasics.pdf">OBJECTIVES: - PseudocodeBasics.pdf</a>
	</li>
	<li>
		<a href="http://web.cerritos.edu/jwilson/SitePages/cpp_language_resources/gaddis_sowc++7e_pdf_appendices_/App_D_Intro_to_Flowcharting.pdf">Z04_GADD6253_07_SE_APP4 - App_D_Intro_to_Flowcharting.pdf</a>
	</li>
</ul>
<p>
	There was one more video, but it requires Adobe Flash to watch.
	As a result, I was unable to watch that video.
</p>
<p>
	One of the great things about pseudocode is that once you&apos;ve used it a while, you start to have half-functional programs after writing out your pseudocode mock-ups.
	By its very nature, pseudocode can express any algorithm that could be spelled out to a computer, and likely, most if not all algorithms that a computer can&apos;t handle.
	Flowcharts suffer from severe limitations though due to their two-dimensional and graphical nature.
	Simple algorithms can be expressed well as flowcharts, and more complex algorithms can be expressed using multi-part flowcharts, but pseudocode has at least as much expressive power as, if not more than, flowcharts.
	I would love to use pseudocode for the project this week, but I&apos;ve been programming for too long.
	My pseudocode looks like actual code, and might actually run if plugged into <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> instead of Python (I think in <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> because I use it daily, I don&apos;t use Python often).
	I fear that as it&apos;s graded by other students, they might think that I missed the point of pseudocode and didn&apos;t do the assignment correctly.
	It&apos;s hard to misinterpret flowcharts as functional code though, so that&apos;s the path that I chose for completing the assignment for the week.
	(Intentionally writing pseudocode that doesn&apos;t look like code would be possible, but it would be a step backwards.)
	Additionally, using a flowchart instead of pseudocode gave me a chance to work with Dia, which I&apos;d never even heard of before this week.
</p>
<p>
	I probably should have put in an effort to build my <a href="https://y.st./en/coursework/CS1101/calculator_flowchart.xhtml">flowchart</a> in <abbr title="Extensible Hypertext Markup Language">XHTML</abbr> and <abbr title="Cascading Style Sheets">CSS</abbr>, for a better file size and easier archival, but I didn&apos;t think of that until I&apos;d finished building it in Dia.
	Besides, it gave me a chance to figure out the basics of Dia.
	I&apos;d say that the main thing that I learned this week was how to set up a basic flowchart using Dia, though I wasn&apos;t able to perfect my use of it by any means.
	My Dia project looked the way that I wanted it to before exporting as a <abbr title="Portable Network Graphic">PNG</abbr>, but strangely, the exported image doesn&apos;t look quite like the project.
	The main discrepancy is in the largest of the error messages that I put in the flowchart.
	In my project, the parallelogram around the text is large enough that the full text is displayed.
	However, in the exported image, the opening single quote is too close to the edge of the shape and the ending single quote overlaps with the border.
	Because of this, it looks like there&apos;s no ending quote at all.
</p>
<p>
	One of the assigned pages for reading says that key words should be in all capital letters.
	This is not a hard requirement, and in fact, I don&apos;t recommend doing it.
	All that it serves to do is make your pseudocode ugly.
	This isn&apos;t problematic in the beginning, I guess, but it becomes a bigger issue as your pseudocode begins to look more like real code.
	(When I say &quot;hard requirement&quot;, I mean an absolute requirement.
	The opposite would be a soft requirement, not an easy requirement.)
	That same page brings up the need for an ending key word in addition to a beginning key word.
	For example, ending an <code>if</code> block needs an <code>endif</code> key word.
	Again, this isn&apos;t a hard requirement because of the indention, but it&apos;s a good idea.
	Another option is to use curly braces or the like, but I personally find the key words such as <code>endif</code> to be more readable.
</p>
<p>
	Once more, I&apos;ve had to submit my discussion response at the last minute, and once more, I&apos;m lucky that anyone had time to respond to it.
	I can&apos;t wait until my move is complete and I have more time and energy to get my coursework completed earlier.
	I didn&apos;t have any particularly noteworthy interactions this week, likely because of time constraints, but I did respond to one student that had an idea that made me wonder.
	They mentioned using pseudocode in documentation.
	How would one do this?
	How would one document code with examples without the examples consisting of real code?
	And what purpose would this serve?
</p>
<p>
	One of the six programming assignments that I graded had some confusing parts, but did meet all the requirements.
	First, it included this comment in the upper comments section:
</p>
<blockquote>
<pre><code># Licence:     &lt;your licence&gt;</code></pre>
</blockquote>
<p>
	So ... what license is it covered by then?
	Additionally, it had this code fragment at the top of the actual code:
</p>
<blockquote>
<pre><code>def main():
    pass

if __name__ == &apos;__main__&apos;:
    main()</code></pre>
</blockquote>
<p>
	It defines a function that does nothing, then calls it if the script is the main one being run, instead of being run as a module.
	What is even the point?
	Technically though, this doesn&apos;t mess with the output of their script, it just has the computer put in a little extra effort for no gain.
	Another submission not only provides actual units in the output, but also shows the same area converted into metric units!
	I should have included the units too, at a bare minimum, but I was too focused on trying to get exactly the expected output, as evidenced by the comments section of <a href="https://y.st./en/coursework/CS1101/t_area.py.xhtml">my code</a>.
	Conversion to metric units would have been a nice touch too.
	I find it a bit interesting that you can tell a bit about the operating system of the user based on their code.
	My text editor, <a href="apt:geany">Geany</a>, displays &quot;invisible&quot; characters for me.
	Because of that, I can see the line terminators.
	On Linux, <abbr title="Berkeley Software Distribution">BSD</abbr>, and OS X systems, the lines end in a line feed.
	On pre-OS X Macs, a carriage return is used instead.
	(I saw no submissions that fit that description though.)
	In submissions that came from Windows users, I saw both a carriage return and a line feed, because I guess that Microsoft likes line terminators to take twice as much space on disk.
</p>
<p>
	When taking the ungraded quiz, it was asked whether this statement was true or false:
</p>
<blockquote>
	<p>
		One of the advantages of flowcharts is that it is hard to modify.
	</p>
</blockquote>
<p>
	How would that possibly be an advantage?
	I mean, it&apos;s true that they&apos;re harder to modify than pseudocode, but that&apos;s a <strong>*disadvantage*</strong>.
</p>
<p>
	Thankfully, the graded quiz wasn&apos;t a pure history quiz.
	Most of the historical information, such as at what university each programming language was invented in, is useless.
	I have trouble retaining information that serves no value.
	Some history questions were asked though, so I did lose some points on those.
	One frustratingly-ambiguous programming question was present too:
</p>
<blockquote>
	<p>
		What output will the following python command produce:
	</p>
	<p>
		&gt;&gt;&gt; percentage = ( 60 * 100) / 55<br/>
		&gt;&gt;&gt; print (percentage)
	</p>
</blockquote>
<p>
	It depends.
	Are we talking about Python2 or Python3?
	At first, I answered according to what Python2 would do.
	For now, I consider Python2 to be the de facto main version of Python.
	Most scripts seem to be written in that version, not to mention that it&apos;s the default version of Python on one of the world&apos;s most-used Linux distributions: Debian.
	More popular operating systems such as Windows don&apos;t even have Python installed by default, so such systems don&apos;t even <strong>*have*</strong> a default to check.
	After a bit though, I changed my answer to the Python3-based answer because that&apos;s what the text book seems to use.
	Later, I came to a question about integer division though, which most people won&apos;t even run into in Python3.
	At that point, I switched my answer back to the Python2-based response.
	Now that I&apos;ve submitted the quiz, it&apos;s too late, and I&apos;m reflecting; I now remember that we learned about the integer division operator in Python3.
	Most likely, that question <strong>*was*</strong> about Python3, which means that I got it wrong.
	It&apos;d be nice if the quiz was more specific and told which version of Python was in use.
	In most cases, simple operators don&apos;t undergo huge changes between versions of a language, but in Python&apos;s case, they had a severe design flaw in the initial implementation and it needed to be fixed in a later version.
	As a result, it <strong>*does*</strong> matter which version of the language that you&apos;re using.
</p>
<p>
	My final thought for this week is probably that the course kept mentioning in several places use of a word processor for writing pseudocode.
	There is a major difference between a text editor and a word processor.
	A word processor is a horribly inefficient tool for working with plain text formats, such as that of pseudocode.
	Word processors are also usually overly-bloated, but that&apos;s not a hard requirement for being a word processor.
	It&apos;s true that you could write pseudocode using a word processor, but a text editor would be a much better option.
	Text editors are designed to work with plain text formats.
	Often times, they provide better tools for doing such, but even when they don&apos;t, they at least default to saving the file in the correct (<code>.txt</code>) format and they don&apos;t have all those text-file-incompatible options such as font-, size-, and color-formating.
	Word processors are almost always the wrong tool for a programmer.
	Word processors are built for formating formal documents, such as résumés and reports, and that&apos;s what they&apos;re good at.
</p>
<h3>Discussion board post drafts</h3>
<blockquote>
	<p>
		Pseudocode is a way to express the plan for a program textually.
		It&apos;s often in a code-like format, but doesn&apos;t always adhere to an actual programming language.
		As a result, compiling or running pseudocode often doesn&apos;t work.
		Instead, it&apos;s sort of like written notes on the details of your program&apos;s process; it&apos;s like the roughest of rough drafts for an essay.
	</p>
	<p>
		A flow chart is a diagram that indicates the path that a program will take.
		It looks nothing like actual code, but it makes it clear how the program is intended to behave.
	</p>
	<p>
		There are three main reasons that I prefer pseudocode over flow charts.
		First off, pseudocode is a great representation of the way that I actually think.
		This doesn&apos;t apply to everyone, but I plan better in text formats than I do graphical formats.
		Second, a plain text editor is all that you need to write pseudocode.
		Flow charts require something more ... clunky.
		You could use an image editor such as the <abbr title="GNU Image Manipulation Program">GIMP</abbr> or you could use specialized software such as Dia.
		In either case, setting up the diagram is simply not as quick or as easy as just typing up what you plan to do.
		For me, speed is often essential, as I don&apos;t have much time to sit down and work.
		If I have to leave partway through the planning stage, I might forget the part of my plan that I haven&apos;t sketched out yet!
		Writing something quickly in pseudocode is a great way for me to express my ideas within a small time slot.
		I can even flesh them out better later if needed, as plain text documents are easier to edit than flow charts.
		Third, real code is also in a text format.
		Well-written pseudocode might be very close to being runnable and only need some minor changes before becoming the first actual implementation of your plan.
		By using pseudocode instead of a flow chat, I can reuse effort instead of starting again.
	</p>
	<p>
		Flow charts might be a better idea for the more graphically-inclined though.
		Some people visualize their programs graphically instead of textually.
		When showing your plan to someone else, a flow chart might be more useful that pseudocode as well.
		Pseudocode comes in a number of &quot;dialects&quot;, so reading the pseudocode of another person might not always be easy.
		For example, my pseudocode contains a high density of <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> tokens.
		People not familiar with <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> may have difficulties reading my pseudocode.
		Flow charts on the other hand, while they have some elements that make them easier to understand once you formally learn to produce them, are incredibly easy to read.
		They&apos;re <strong>*so*</strong> easy to read in fact that there exist flow charts that explain how to read flow charts; and they&apos;re effective for their target audience, people that don&apos;t know what flow charts are.
	</p>
	<p>
		As mentioned previously, pseudocode lacks much of the universality and intuitiveness of flow charts.
		I can also be a bit more verbose, which some people view as a bad thing.
		For the graphically-minded, it can also be less clear than a flow chart.
	</p>
	<p>
		The main drawback for me with flow chats is the need for special software to create and manipulate them.
		You can&apos;t simply use a basic text editor with them.
		Additionally, flow charts force you to put in a lot more effort.
		While you ony have to plan once, you&apos;re basically expressing your process twice, as you need to first express it graphically as a flow chart then later express it textually as actual code.
	</p>
</blockquote>
<blockquote>
	<p>
		I&apos;ve never heard of using pseudocode for documentation purposes.
		I&apos;ve only seen it used for planning and (when offering help to someone without knowing what language that they&apos;re working with) examples of how to structure a program.
		In what way would you use it in documentation?
	</p>
</blockquote>
<blockquote>
	<p>
		I like the way that you phrased that.
		Indeed, both flowcharts and pseudocode are ways of expressing algorithms.
		They don&apos;t express them in a way in which the computer can understand, but the ideas expressed are algorithms none the less.
		I also like your explanation as to when you&apos;d use each.
		Both pseudocode and flowcharts have their time and place.
	</p>
</blockquote>
<blockquote>
	<p>
		The fact that flowcharts are so hard to modify is a bit of a deterrent for using them, to be honest.
		However, they&apos;re easier to modify if you keep their &quot;source&quot;.
		I think that a flow chart is sort of like software in that reverse engineering them is more complicated than it needs to be.
		Instead of saving just a <abbr title="Portable Network Graphic">PNG</abbr> version of the flowchart, you should also save the raw project.
		In <a href="apt:dia">Dia</a>, this would be the file with the <code>.dia</code> file extension.
	</p>
</blockquote>
<h2 id="Unit4">Unit 4</h2>
<p>
	I started with the <a href="https://y.st./en/coursework/CS1101/tryme3.py.xhtml">programming assignment</a> again this week.
	The main difficulty in the assignment this week is the ambiguity.
	It says to define two functions.
	Defining them does not mean calling them.
	It says that the second function defined should be called on the last line of the file.
	Basically, this means that we need to define two functions and call one of them.
	However, the assignment also says that we should separate the output of the two functions to make it easier to grade.
	The first function was never called though, so there&apos;s nothing to separate.
	As such, I can only assume that we&apos;re supposed to actually call both functions.
	I hope that I don&apos;t get marked down for doing that.
	Aside from that, the only problems were simply minor incontinences.
	For example, I&apos;m used to being able to duplicate lines using &quot;control&quot; + &quot;d&quot;, but <abbr title="Integrated Development and Learning Environment">IDLE</abbr> doesn&apos;t have that feature.
	I&apos;m also used to being able to insert tab characters using the &quot;tab&quot; key, but <abbr title="Integrated Development and Learning Environment">IDLE</abbr> doesn&apos;t do that either, at least not by default.
	Only after completing the assignment for the week did I find the not-so-obvious setting that allowed me to reclaim my tab key and set it to its actual, intended purpose.
</p>
<p>
	When I tested the output to my script from within <abbr title="Integrated Development and Learning Environment">IDLE</abbr>, I found that instead of printing blank lines, <code>new_line()</code> was printing lines with pairs of parentheses!
	At first, I thought that Python was interpreting the parentheses at the end of the call to <code>print</code> as a string somehow.
	That didn&apos;t make any sense though; there were not quotation marks, no string delimiters.
	I remembered that the Python developers made a big deal about the <code>print</code> key word in Python2 being replaced by the <code>print()</code> function in Python3 though, so I tried removing the parentheses to see what would happen.
	While I can use the <code>python3</code> command on my command line to run things with Python3, <abbr title="Integrated Development and Learning Environment">IDLE</abbr> (which the assignment instructions said to use when completing the assignment) is still using Python2.
	Sure enough, that fixed the problem!
	Now to try running it on the command line in Python3.
	The &quot;fix&quot; broke it for Python3, though the original version ran fine in Python3.
	I decided that without parentheses, Python3 must be interpreting my statement as an expression without an assignment.
	Functions in Python are contained in variables, so simply putting any valid in-use variable name on a line by itself with have the same effect: none.
	Likewise, I think that Python2 is interpreting the empty parentheses as a tuple or something.
	It&apos;s printing the string representation of a tuple, followed by a line feed.
	Changing the call to be <code>print(&quot;&quot;)</code> allows it to work as desired in both versions, providing cross-version compatibility.
</p>
<p>
	To be clear, I&apos;m using Python3 on the command line, where both Python2 and Python3 are available, but <abbr title="Integrated Development and Learning Environment">IDLE</abbr> does not seem to have the option to go into Python3 mode.
	Because we&apos;re required to use <abbr title="Integrated Development and Learning Environment">IDLE</abbr> for the assignments, I&apos;m stuck using Python2 for any test runs from within <abbr title="Integrated Development and Learning Environment">IDLE</abbr>.
</p>
<p>
	The entire reading assignment this week is from the textbooks mentioned in <a href="https://y.st./en/coursework/CS1101/#Unit1">Unit One</a>.
	It looks like this week, we learn the term &quot;composition&quot;.
	That&apos;s actually one of the terms that we were tested on last week.
	I got that question right because I&apos;ve been programming a while, but for beginning-level programmers, it&apos;s probably unfair to test them on terms before we get a chance to cover them.
	The textbook also also says that you &quot;should&quot; avoid using the same name for both a variable and a function.
	&quot;Should&quot; is the wrong word; more like &quot;must&quot;.
	&quot;Should&quot; implies that there is a choice.
	However, in Python, functions are objects, which means that functions are actually contained within variables.
	The book kind of hints at the fact that functions are objects, but doesn&apos;t even touch on the implications of this as far as variables go.
	If you give a function the same name as a variable, the variable is overwritten by the function definition.
	If you name a variable the same thing as a function, the reverse will happen and the variable&apos;s value will overwrite the function definition.
	It is not possible to have to variables with the same name (at least not within the same scope), so a function and a non-function variable cannot share a name in Python.
	Continuing, the book says that defining a function creates a variable of the same name, but this seems to imply that the variable is separate from the function, not acknowledging that the variable <strong>*contains*</strong> the function, and that without the variable, the function has no separate name.
	For example, take the code below:
</p>
<blockquote>
<pre><code>def example():
	pass

new_name = example
del example

new_name()
example()</code></pre>
</blockquote>
<p>
	In the example above, <code>new_name()</code> will be called successfully.
	However, <code>example()</code> will not.
	It&apos;s variable was deleted, and without it, there is no way to access the function via that name.
	Instead, a Name Error will be raised.
	The book also mentions that the convention in Python is to indent by four spaces.
	This is true, but I have no idea why.
	<a href="https://y.st./en/opinion/code_indentation.xhtml">Spaces and tab characters both have different semantic value.</a>
	Semantically speaking, a space character is the wrong character for indention.
	Spaces, on the other hand, are word (or token) separators.
	The book also says that you can avoid certain problems caused by the mixing of tabs and spaces is to use spaces exclusively.
	This is <strong>*extremely*</strong> misleading.
	It makes it sound like the tab characters are problematic, when they&apos;re not.
	The same problem can be avoided by using tab characters exclusively and never indenting using space characters.
	More important than which character you use to indent with is that you pick a character and stick with it.
	Some people indent semantically, which means using the tab character.
	Some people indent with spaces instead.
	As long as you pick a convention and stick with it, you&apos;ll run into less bugs.
	The book also says that tab characters and space characters are invisible.
	This is exactly one of the reasons that I don&apos;t like <abbr title="Integrated Development and Learning Environment">IDLE</abbr>.
	In a reasonable text editor built with programming in mind, those characters are either visible by default or can be set to be visible.
	For example, check out the screenshot below.
</p>
<img class="weblog-header-image" src="/img/CC_BY-SA_4.0/y.st./coursework/CS1101/visible_whitespace.png" alt="visible whitespace" width="419" height="129" />
<p>
	With a proper text editor, there is no confusion between tabs and spaces.
	Even line feed characters (and carriage return characters, when present) are visible!
	Personally, I use Geany, but Gedit is also known to have this functionality.
	Both offer syntax highlighting as well for several languages, including Python, and they both run on Linux and more popular systems such as Windows.
	For any Windows users, I also recommend Notepad++, which again, will show you whitespace and highlight your syntax.
	Unfortunately, Notepad++ is Windows-specific and won&apos;t run on Linux.
</p>
<p>
	I feel like I&apos;m nitpicking with this textbook a lot.
	If it were under a free culture license, I&apos;d probably fix the errors and send the corrections to the author (who might or might not actually incorporate them into the book).
	It&apos;s not my job to fix proprietary books though.
</p>
<p>
	We had less assignments to grade this week than last week.
	The first one that I graded was a flowchart.
	The main thing about it that I found noteworthy was that it greatly simplified the step of computing the answer based on the operator.
	In <a href="https://y.st./en/coursework/CS1101/calculator_flowchart.xhtml">my own flowchart</a>, I handle each operator separately.
	I think that I did this because as a programmer, I don&apos;t think that there&apos;s a way to handle this situation without branched code (which is what I simulated in my flowchart), the <code>eval()</code> function (which is messy and almost always the wrong way to do things), or a custom function (which is heavily overkill for this situation).
	However, a flowchart isn&apos;t code.
	It doesn&apos;t have to play by the same rules as code.
	It might have been better for me to adopt a simpler, higher-level view in my flowchart like this other student had.
</p>
<p>
	The next submission was pseudocode, but I couldn&apos;t understand what it was trying to say.
	Strange indention made it difficult to decipher, 
	The code began with an indented block with no particular reason to indent, for example.
	The <code>while</code> statement beginning the first understandable block was then unindented.
	I finally deciphered a part near the end to be a set of nested <code>if</code> statements, where each new <code>if</code> block was in the previous one&apos;s <code>else</code> block.
	if a basic <code>elseif</code> was used instead, it would be easier to understand with the formatting that it had.
	Using <code>if</code> from within <code>else</code> is fine, but in that case, each new <code>if</code> should be indented one more level than the last to make it readable.
	At the end of the pseudocode, I think that the author intended the process to loop back to the beginning under some conditions, but instead, it just asks for input again then halts.
	Other parts of the code are nested when they shouldn&apos;t be.
	I hate to be a nag, but after I finally managed to decipher the pseudocode, I found that it didn&apos;t meet half of the requirements: those of checking the input for problems.
</p>
<p>
	The final submission that I graded was also pseudocode and also didn&apos;t do any error checking.
	however, it was much more concise, and the little indentation that was used was used in exactly the right places.
	While it took several minutes to figure out what the last submission did, this one could be understood in a glance.
</p>
<p>
	I didn&apos;t do as well on the ungraded quiz as I&apos;d like to have, but I still did alright.
	I got one question wrong because I wasn&apos;t quite sure what it was asking.
	The other two that I got wrong were due to my genuine lack of knowledge in Python.
	Due to recent events, I should have a lot more time to study in coming weeks though.
</p>
<p>
	The discussion board also went smoother than in past weeks, and I was able to submit my first post fairly early on this time.
	It looks like I was able to put to words something that one of the other students had been thinking, which was nice.
</p>
<p>
	Unfortunately, I wasn&apos;t able to complete the exercises this week.
	I normally do them, and I might do this week&apos;s exercises next week to catch up.
	This week was very demanding for me, both physically and emotionally, so as the exercises were ungraded, they had to be put aside.
	That said, my final thought for the week is that a great burden was lifted from my shoulders in these past couple days.
	THis should free me up much more to pursue my education and excel in class.
</p>
<h3>Discussion board post drafts</h3>
<blockquote>
	<p>
		A parameter is a type of local variable name that exists only within the scope of the function that it&apos;s defined in.
		In many ways, it&apos;s the same as any other local variable defined within the context of the function.
		However, parameters have a special property as well.
		They have no initial value, and their name binds to a value passed as an argument into the function.
		This allows the function to be defined to work with data passed into it instead of always outputting identical information or performing identical actions.
	</p>
	<p>
		I suppose that in a way, you could say that a parameter is a variable name with no value.
		A parameter is a value with no variable name.
		When you call a function, the values are bound to the variable names to form local variables until the function completes.
	</p>
	<p>
		Of course, a variable could be passed in a function call, but it&apos;s not really the variable that&apos;s being passed into as an argument at all.
		Instead, it&apos;s the value of that variable that gets used as the argument.
		Any valid expression can be passed in a function call because the expression itself isn&apos;t what gets passed as an argument.
		Instead, expressions are evaluated to find their value, and it&apos;s that value that&apos;s actually being used as an argument.
		The reason that variables can be used as arguments in function calls is because when evaluated, the result is their value.
		Function calls can also be passed in because they&apos;re evaluated and result in their return value.
		The same applies of course to mathematical equations and anything else that can be evaluated in Python.
	</p>
</blockquote>
<blockquote>
	<p>
		If you&apos;re talking about calling a function from within a function, and using a parameter of the outer function as an argument for the calling of the inner function, then yes, you can do that.
		You can even call the same function, though I don&apos;t recommend doing that with identical input (such as by passing the parameter as an argument).
		You can treat the parameter as you would any other local variable.
		You can call the parameter <strong>*as*</strong> a function, you can pass it as an argument <strong>*to*</strong> a function, and you can even assign a new value to that variable.
	</p>
</blockquote>
<blockquote>
	<p>
		Code reuse is probably the main and most important feature of user-defined functions.
		It&apos;s helpful not to have to write the same code several times or write it once and paste it into several places.
		Additionally, code reuse from functions allows you to update only a single copy of the code and have every instance of its use in your script be updated as well.
		It&apos;s common also to use it to make code look simpler and easier to read.
	</p>
	<p>
		One topic with functions that I hope that we cover is recursion.
		So far, what we&apos;ve done with user-defined functions could be accomplished without them, but our functions make the code easier to read and update.
		However, recursion is something that cannot really be accomplished in Python without user-defined functions.
		Essentially, it allows you to have your script work its way through structures that are nested arbitrarily deep.
		It might not make much sense now, but it&apos;ll be a vital tool later on when programming certain larger projects.
	</p>
</blockquote>
<blockquote>
	<p>
		That&apos;s a useful way to think about parameters.
		They are like settings for the function&apos;s code block to work with.
		The same code block may need to run again with different settings, so different arguments would need to be passed in.
	</p>
</blockquote>
<blockquote>
	<p>
		Easier debugging is an important aspect of code reuse, such as that of user-defined functions.
		User-defined functions can also help you get started on code that you don&apos;t know how to write yet.
		For example, you might have a pretty good idea of what you want your code to do, but you might still be unsure how to implement specific parts.
		You can define dummy functions that don&apos;t do anything and use them in your code as it they did what you need done.
		Later, you can go back and define real functions, and your code will automatically use the real functions and you&apos;ll get the result that you are after.
	</p>
</blockquote>
<h2 id="Unit5">Unit 5</h2>
<p>
	My professor has freed me from <abbr title="Integrated Development and Learning Environment">IDLE</abbr>!
	I no longer have to use it for assignments.
	It was interesting to get to try it, but it&apos;s not an editor that I recommend for serious use.
</p>
<p>
	The programing assignment for this week is to take a conceptual model and turn it into an actual program.
	Two conceptual models are provided, one is pseudocode and one as a flowchart.
	This seems like an easy task until you notice that the two models contradict one another.
	The basic issue is that the pseudocode allows the use of zeros while the flowchart does not.
	The obvious answer is to take all the programmable qualities of both models, which means disallowing zeros, but the contradiction doesn&apos;t stop there.
	The pseudocode uses an invalid operator as a signal to exit the program.
	The flowchart instead prompts for a new operator.
	If this were my own project, the solution would be easy.
	Prompt for valid operators and only check for zeros as divisors in division (zeros anywhere else are fine).
	This is graded though, and I can&apos;t see the grading criteria until it&apos;s too late.
	I ended up going with the flowchart version, as it exemplifies the hypothetical calculator we were working with two weeks ago, so it would be more likely to fit the grading rubric.
</p>
<p>
	It was kind of fun to set up the prompts.
	I also experimented with indention to see how picky Python would be.
	I don&apos;t like to indent comments, and in my opinion, I shouldn&apos;t have to.
	Python agrees.
	Python also allowed me to not indent empty lines.
	As long as a given line didn&apos;t have any instructions for Python to follow on it, it ignored the indention level.
	First, I wanted to check to see if my input was a number.
	You can never trust input from users, and trying to do math with strings would be problematic.
	Before I&apos;d put together a solution though, I realized that <strong>*all*</strong> input from users will be strings!
	I needed a way not only to weed out bad input, but also to parse the input.
	Proper output would require that I treat integers and floats, both input as strings, differently.
	<code>5 * 2</code> should output <code>10</code>, not <code>10.0</code>, while <code>3 * 2.5</code> should output <code>7.5</code>.
</p>
<p>
	After completing the code, debugging in Python3 as I went, it was time to test it in Python2.
	A good programmer would make the code run in both versions.
	Besides, it&apos;s a learning experience.
	Running the script in Python2 raised strange errors though.
	It took forever to figure out what the problem was.
	It turns out that Python3 does away with Python2&apos;s <code>input()</code> function and renames Python2&apos;s <code>raw_input()</code> function to be Python3&apos;s <code>input()</code> function.
	Python2&apos;s <code>input()</code> function tries to evaluate the user&apos;s input as an expression!
	One should never trust user input like that.
	Assuming that the user only input valid numbers, it would have removed the need to convert string input into numbers, but the cost is too high.
	Likewise, operators couldn&apos;t be input without quotation marks around them unless I used <code>raw_input()</code>, and Python3 doesn&apos;t have a function by that name.
	In Python though, everything that isn&apos;t a language construct is an object.
	That means that functions are objects.
	All I had to do was check for the presence of <code>raw_input</code> and rename it <code>input</code> if it existed.
	This (along with <code>from __future__ import division</code>) upgraded Python2 to behave like Python3, so the <a href="https://y.st./en/coursework/CS1101/mycalc.py.xhtml">script</a> now runs in both.
</p>
<p>
	Now, I had the problem of the output file: I was supposed to include one.
	The script takes user input though, so I can&apos;t enumerate all output that it produces.
	I ended up just showing a session in which I tried to enter invalid input and divide by zero (to show the error messages), then divided by two (to show the displayed result and exit the script).
</p>
<p>
	After completing the discussion assignment, I graded assignment submissions from last week.
	It seems that I&apos;m not the only one that trouble getting <code>print()</code> to function!
	The first submission that I graded used the <code>print</code> key word from Python2.
	The script doesn&apos;t have any output at all in Python3.
	I gave it full credit, but explained in the feedback comments how to make it work better next time.
	The next submission used the string &quot;----------------------------------------------------------------------&quot; instead of blank lines.
	What were they thinking?
	Do they not know what a <strong>*blank*</strong> line is?
	More to the point, did they not read the predefined definition of <code>blank_line()</code>?
	In any case, I had to mark them down for not following directions.
	The final submission I graded was almost the perfect implementation.
	It used loops, which I&apos;d considered doing, but decided not to.
	The loop would have taken up as many lines as simply calling the function three times would, in the case of <code>nine_lines()</code>, and I called <code>nine_lines()</code> twice from within <code>clear screes()</code>, along with <code>three_lines()</code> twice and <code>new_line()</code> once so that function could build off the function before it (<code>nine_lines()</code>), so a loop over <code>nine_lines()</code> and <code>three_lines()</code> would have been overkill.
	This submission instead used the <code>range()</code> function to create arrays to iterate over, one in each of the two main functions.
	<code>clear_screen()</code>&apos;s loop called <code>new_line()</code> instead of having anything to do with <code>nine_lines()</code>.
	I think a <code>while</code> loop would be better than a <code>for</code> loop, as the array created was entirely ignored in the loop, but the submitted solution was elegant none the less.
</p>
<p>
	The reading assignment for the week included chapters from both textbooks mentioned in <a href="https://y.st./en/coursework/CS1101/#Unit1">Unit 1</a>, as well as a video about <a href="https://www.youtube.com/watch?v=D0Nb2Fs3Q8c">while loops in Python</a>.
	By the time I got to the reading assignment, I was <strong>*way*</strong> late to start the reading.
	The events of last week set me back by two days, and I was able to recover one of them that week.
	This week&apos;s been about recovering the second day, which I was able to do, so I can start next week with a clean slate.
	Mostly.
	I&apos;m still behind in the ungraded exercises.
</p>
<p>
	The textbook presented an interesting use case for modulus division.
	It mentioned using it to see if an integer is divisible by another integer, which I think is a pretty common use case, but it also mentioned using it to extract the least-significant digits of an integer.
	I&apos;m not sure what that&apos;d be good for off the top of my head, but it sounds like something that could be useful in some corner cases.
</p>
<p>
	Finally, with the reading complete, I took the ungraded quiz to finish for the week.
	Thankfully, this quiz was all about functionality and involved no history questions of any kind.
	Being bad at remembering history doesn&apos;t make me a bad programmer, but it makes me look like one when I&apos;m getting answers wrong on a basic programming course quiz because it asks history questions instead of programming questions.
</p>
<h3>Discussion board post drafts</h3>
<blockquote>
	<p>
		The <code>=</code> and <code>==</code> operators perform very different roles, but have some similarities.
		It&apos;s worth noting that both operators have return values, just like functions.
		(A function&apos;s return value, if not explicitly defined, is <code>None</code>.
		A function always returns a value though.)
	</p>
	<p>
		<code>==</code> is an operator used in an expression that tests for equality of two subexpressions.
		The return value is either <code>True</code> if the subexpressions are equal or <code>False</code> if they aren&apos;t.
		This expression and return value can be used anywhere that another value could be used.
		For example, <code>if False == True:</code> is valid Python, as long as it begins a block.
		<code>my_variable = q == v</code> is also valid, and assigns a <code>True</code> or <code>False</code> value to <code>my_variable</code>.
	</p>
	<p>
		That brings us to the assignment operator, <code>=</code>.
		The subexpression on the left side of the operator must be a variable name, and the operator assigns the value of the subexpression on right to that variable.
		Strangely though, this operator still returns a value: the value that it assigned to the variable.
		That means that this is valid in Python: <code>var_x = var_y = 2 + 3</code>.
		It assigns the value <code>5</code> to <code>var_y</code>, then assigns the value returned by <code>var_y = 2 + 3</code> (which is also <code>5</code>) to <code>var_x</code>.
		Strangely, this is invalid in Python, but works in other languages: <code>if var_z = 5:</code>.
		In theory, it should assign the value of <code>5</code> to <code>var_z</code>, then evaluate <code>5</code> as <code>True</code> and run the block of code.
		Most likely, Python disallows this because it&apos;s a common mistake to type that and there&apos;s little use for using an assignment operator in the conditional test of an <code>if</code> statement.
	</p>
	<p>
		Long story short, if you&apos;re trying to set the value of a variable, use the assignment operator, <code>=</code>.
		If you&apos;re trying to check for equality, use the equality operator instead, <code>==</code>.
		This will often, though not always, be used for loops and conditional blocks.
	</p>
</blockquote>
<blockquote>
	<p>
		You&apos;re right, it&apos;s good to note that a variable can only hold one value at a time.
		Assigning a new value causes the old one to be lost.
		It&apos;s also worth noting that because Python is a weakly-typed language, a variable might hold different types of values at different points in the script.
		For example, a variable that holds an integer value might be assigned a string value upon next value assignment.
	</p>
</blockquote>
<blockquote>
	<p>
		That&apos;s a nice concise, clear explanation with examples.
		You might want to put the pound sign before the parenthesis though to include it in the comment.
		Additionally, in Python, True and False begin with capital letters.
		Otherwise, Python thinks that you mean user-defined variables called "true" and "false".
	</p>
</blockquote>
<blockquote>
	<p>
		I like how you point out that the assignment operator, <code>=</code>, isn&apos;t only used to assign values to variables.
		It can also assign values to elements in an array or properties of an object.
	</p>
</blockquote>
<h2 id="Unit6">Unit 6</h2>
<p>
	My challenge for the week was figuring out how to properly complete the programing assignment.
	The instructions seem even more self-contradictory and ambiguous that usual.
	They say that the function should prompt for user input, but also that it should get its data from arguments instead.
	I decided to have the function have parameters, but have the script prompt for input to pass into the function as arguments.
	I&apos;m hoping that&apos;s what the assignment meant to do.
</p>
<p>
	As usual, pseudocode would be the easier way to plan in this assignment, but a flowchart has three advantages: it won&apos;t be mistaken as actual code, I won&apos;t need to intentionally downgrade my pseudocode style to mitigate the first problem, and the flowchart makes for a more interesting thing to look at in my archive.
	I wanted to create a subprocess in the flowchart for the function in the script, a subprocess with three ending points; the function itself would have three <code>return</code> statements, so why shouldn&apos;t the flowchart reflect that?
	I couldn&apos;t remember for sure if that was allowed though.
	It <strong>*should*</strong> be allowed, but going back to <a href="https://y.st./en/coursework/CS1101/#Unit3">Unit 3</a>, I couldn&apos;t find any indication that it <strong>*is*</strong> allowed.
	I decided to play it safe, and use a single ending point in the subprocess.
	Doing so required adding a variable to the flowchart that would never be added to the actual script.
</p>
<p>
	I was a step away from completing my code, but I had to check something really quickly first.
	Obviously, the user input needed to be converted to a numeric type before being compared, but some user input can&apos;t be converted to integers or floating points.
	I have a habit of poking things.
	I check corner cases on all sorts of things, even when it&apos;s not code and even when it&apos;s not something I&apos;m building.
	This does carry over to my code-writing though.
	Instead of adding the type conversion I needed to complete my script, I instead ran it as-is.
	I tried to compare &quot;q&quot; to &quot;a&quot; to watch the script break.
	... but it didn&apos;t break.
	Strings can be compared using the <code>&gt;</code>, <code>==</code>, and <code>&lt;</code> operators in Python!
	Comparing single-digit number strings even provides the expected results.
	Comparing multi-digit number strings doesn&apos;t work as expected though.
	Or to be more precise, it works <strong>*exactly*</strong> as expected.
	Numeric strings are strings, and these comparison operators seem to basically function to alphabetize strings.
	That means that the string &quot;20&quot; is less than the string &quot;3&quot;.
	<strong>*This is as it should be.*</strong>
	However, it raises an interesting question: should my script be comparing strings or comparing numbers?
	The input the assignment specifies is single-digit number strings, so either way, the output will remain the same.
	That means that this decision shouldn&apos;t affect my grade; the question is of which is the right way to do things, not which will result in getting credit for the assignment.
	After going back and forth a while, I decided to add a prompt at the beginning to allow users to choose which type of comparison to have the script make, then implemented both options.
</p>
<p>
	With the <a href="https://y.st./en/coursework/CS1101/bool.py.xhtml">script</a> complete and working in Python3, I tried it in Python2.
	This time, Python2&apos;s <code>print</code> key word was reading my multiple arguments to the Python3 <code>print()</code> function as a tuple.
	I could remove the parentheses, but that caused a syntax error error in Python3.
	In other words, I couldn&apos;t conditionally call <code>print()</code> in Python3 and use the <code>print</code> key word without parentheses in Python2, as merely having a line with the Python2 usage would prevent the script from running in Python3.
	I ended up using concatenation to fix it.
	It&apos;s not pretty, but it makes the code portable.
</p>
<p>
	When I went to submit my assignment this week, I quickly noticed the usual format-it-as-a-Microsoft-Word-document requirement was absent this week.
	In every other course at I&apos;ve taken at University of the People, OpenOffice documents have also been accepted.
	More importantly though, the submission form has an actual <code>&lt;textarea/&gt;</code> each week.
	Why not make use of that?
	It&apos;s much easier for graders, as we don&apos;t have to download the assignment files to our hard drives before grading; we can simply read the assignment submission on the same Web page as the grading form.
	I did upload my script as a file in case someone wants to run it, but the flowchart, script, and output are all visible without a download as well.
</p>
<p>
	Exercise 7.5 this week asks us to implement some complex mathematical formula in Python, but I have no idea how to do that.
	I don&apos;t even understand the formula!
	It uses symbols I&apos;m unfamiliar with.
	As this is a textbook on programming, not maths, you&apos;d think it wouldn&apos;t be throwing complex mathematical expressions at us without explaining how they work.
	Sheesh.
</p>
<p>
	There wasn&apos;t anything particular noteworthy in the reading assignment this week aside from the complex formula.
	It was all pretty straightforward.
	In addition to some chapters in our textbooks to read, we also had two videos to watch:
</p>
<ul>
	<li>
		<a href="https://www.youtube.com/watch?v=6qCQB8E5bkI">Diagramming What Happens with a Function Call</a>
	</li>
	<li>
		<a href="https://www.youtube.com/watch?v=JwO_25S_eWE">Defining a Factorial Function</a>
	</li>
</ul>
<p>
	The videos seemed overly-complex, but maybe that&apos;s just me.
	I learn better from reading text than watching videos.
	All of it was stuff I knew though, so I followed along just fine, it just seemed like there were quicker and easier ways to explain things.
	I got this week&apos;s reading assignment done a little early, so I was able to go back and complete some of the exercises from the past two units that I&apos;d had to skip for the time being.
	However, I had no days off from work this week, so I wasn&apos;t able to complete it all.
	One of the exercises I was supposed to complete last unit taught me something about triangles.
	There&apos;s something called a degenerate triangle, and the sum of two of the sides are equal to that of the remaining side.
	I didn&apos;t think that was actually considered a triangle.
	I mean, clearly it&apos;s flat and two of the sides combine into one; one side that perfectly overlaps the other side.
	What kind of triangle is that?
	(That was rhetorical; obviously the answer is that it&apos;s a degenerate triangle.)
	Also from what I caught up on from last week, I needed to install <a href="http://greenteapress.com/thinkpython/swampy/">Swampy</a>.
	Swampy depends on Tkinter, which seems to already be installed on my system, but only the Python2 version of it was present.
	To get it working in Python3, I needed to run <code>sudo aptitude install <a href="apt:python3-tk">python3-tk</a></code> on the command line.
	Next, I needed to install Swampy, using the command <code>sudo pip install swampy</code>.
	I&apos;m always very uneasy about installing software from outside the package manager like this.
	I mean, I guess pip is another package manager, but using one and only one package manager seems like the safest and most stable option.
	When I checked on the install, I saw it failed.
	It couldn&apos;t reach the remote file.
	I&apos;d totally forgotten that I don&apos;t have a &quot;real&quot; Internet connection at home.
	Pip was no doubt trying to make a proxyless connection to the network, which isn&apos;t possible from here.
	Everything network-related on my laptop has to be run through my mobile&apos;s <abbr title="The Onion Router">Tor</abbr> instance, or it won&apos;t go through.
	Running <code>sudo torsocks pip install swampy</code> fixed the problem, and I was able to install Swampy.
	That only worked to install it for Python2 though; Python3 still couldn&apos;t access the <code>swampy</code> module.
	At that point, I gave up and just decided to work on the exercises in Python2.
	I ran out of time to actually get anywhere with the turtle exercise that uses Swampy though.
</p>
<p>
	Two of the assignments submissions I graded this week were fine examples.
	One though ... one was full of problems.
	Like ... All I can think is that they didn&apos;t actually try running their script before submitting it, even.
	The output file is incomplete, the script doesn&apos;t check for zeros in the right places, though it does check for zeros in a wrong place ... it even specifies that they user may enter any of nine operators, though five of them don&apos;t actually <strong>*do*</strong> anything ...
</p>
<p>
	Lastly, I took the ungraded and graded quizzes.
	On the ungraded quiz, this question appeared:
</p>
<blockquote>
	<p>
		A loop where the terminating condition is never achieved is called an _______
	</p>
</blockquote>
<p>
	One of the options was:
</p>
<blockquote>
	<p>
		d. for .. ever loop
	</p>
</blockquote>
<p>
	That gave me a good laugh!
	Another question asked about the execution of code, and used the <code>+=</code> operator.
	Python has that!?
	I thought I remembered being taught that such an operator wasn&apos;t present in Python, which was a mild inconvenience, seeing as I&apos;m used to using it all the time in <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>.
	I tested it out though, and both <code>+=</code> and <code>-=</code> are implemented in both Python2 and Python3.
	I was either taught incorrectly before or I misremembered.
	In any case, I had need for decrementing in my code submission for the week, so I fixed my code which previously read <code>iterations = iterations - 1</code> to do things the <strong>*right*</strong> way: <code>iterations -= 1</code>.
</p>
<p>
	Life has settled into a better-than-normal state, or at least a better-than-was-previously-normal state.
	I have no doubt that it&apos;ll take me some time to fully recover, but even just now, I have so much more time and energy for my studies than I&apos;ve had in the past.
	The future, or my educational future at the very least, is looking bright.
</p>
<h3>Exercises</h3>
<h4>From <a href="https://y.st./en/coursework/CS1101/#Unit5">Unit 5</a></h4>
<h5>Exercise 5.1</h5>
<blockquote>
<pre><code>def check_fermat(a, b, c, n):
	if n &lt; 2 and a**n + b**n == c**n:
		print(&quot;Holy smokes, Fermat was wrong!&quot;)
	else:
		print(&quot;No, that doesn&apos;t work.&quot;)

def prompt():
	print(&quot;The goal is to find integer values for a, b, c, and n, where n is greater than two and this equation holds true:\n\ta**n + b**n == c**n\n&quot;)
	a = int(input(&quot;Please enter a value for a:\n&gt;&gt;&gt; &quot;))
	b = int(input(&quot;Please enter a value for b:\n&gt;&gt;&gt; &quot;))
	c = int(input(&quot;Please enter a value for c:\n&gt;&gt;&gt; &quot;))
	n = int(input(&quot;Please enter a value for n:\n&gt;&gt;&gt; &quot;))
	check_fermat(a, b, c, n)</code></pre>
</blockquote>
<h5>Exercise 7.1</h5>
<blockquote>
<pre><code>def print_n(s, n):
	while n:
		print(s)
		n = n - 1</code></pre>
</blockquote>
<h4>From <a href="https://y.st./en/coursework/CS1101/#Unit6">Unit 6</a></h4>
<h5>Exercise 6.1</h5>
<p>
	Um ...
	That&apos;s pretty much the <a href="https://y.st./en/coursework/CS1101/bool.py.xhtml">assignment for the week</a>.
</p>
<h5>Exercise 6.2</h5>
<blockquote>
<pre><code>import math
def hypotenuse(a, b):
	return math.sqrt(a**2+b**2)</code></pre>
</blockquote>
<p>
	(The exercise says to record each step of the process of developing this, but it was too simple of an exercise to require more than one step to develop.
	Simply writing the three lines above creates a functional function.)
</p>
<h5>Exercise 6.3</h5>
<blockquote>
<pre><code>def is_between(x, y, z):
	if x &gt; y:
		return False
	elif y &gt; z:
		return False
	else:
		return True</code></pre>
</blockquote>
<h5>Exercise 6.5</h5>
<blockquote>
<pre><code>def ack(m, n):
	if m == 0:
		return n + 1
	elif m &gt; 0 and n == 0:
		return ack(m-1, 1)
	elif m &gt; 0 and n &gt; 0:
		return ack(m-1, ack(m, n-1))

print(ack(3, 4))</code></pre>
</blockquote>
<p>
	Incrementing <code>m</code> by one or <code>n</code> by three is enough to cause a recursion depth error.
</p>
<h5>Exercise 6.6</h5>
<blockquote>
<pre><code>def first(word):
	return word[0]

def last(word):
	return word[-1]

def middle(word):
	return word[1:-1]

def is_palindrome(string):
	if len(string) == 0:
		return True
	elif first(string) == last(string):
		return is_palindrome(middle(string))
	else:
		return False</code></pre>
</blockquote>
<h5>Exercise 6.7</h5>
<p>
	This exercise doesn&apos;t provide a base <code>True</code>case.
	If <code>a</code> is not divisible by <code>b</code>, <code>False</code> is returned.
	Otherwise, <code>is_power(a/b, b)</code> is returned.
	At some point, <code>a</code> will be too small to be divisible by <code>b</code> and <code>False</code> will be returned.
	I&apos;ve added a stipulation to my function to say that if <code>a</code> is equal to <code>b</code>, it&apos;s a power of it, but that&apos;s technically not as the instructions said to do.
</p>
<blockquote>
<pre><code>def is_power(a, b):
	if a == b:
		return True
	elif a % b == 0:
		return is_power(a//b, b)
	else:
		return False</code></pre>
</blockquote>
<h5>Exercise 6.8</h5>
<blockquote>
	<pre><code>def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a%b)</code></pre>
</blockquote>
<h5>Exercise 7.2</h5>
<blockquote>
<pre><code>def square_root(a):
	epsilon = 0.0000001
	x = a
	while True:
		y = (x + a/x) / 2
		if abs(y-x) &lt; epsilon:
			break
		x = y
	return y</code></pre>
</blockquote>
<h5>Exercise 7.3</h5>
<blockquote>
<pre><code>import math

def square_root(a):
	epsilon = 0.0000001
	x = a
	while True:
		y = (x + a/x) / 2
		if abs(y-x) &lt; epsilon:
			break
		x = y
	return y

def test_square_root():
	i = 0
	while i &lt; 9:
		i = i + 1
# Floats are unreliable, so I don&apos;t feel comfortable incrementing a
# float. Instead, let&apos;s store and increment an integer, then cast to a
# float.
		col0 = float(i)
		col1 = square_root(col0)
		col2 = math.sqrt(col0)
		col3 = abs(col1-col2)
# The exercise doesn&apos;t explain how it wants the data formatted, but
# this setup makes the formatted data look like the example, so that&apos;s
# what I&apos;m going with. However, it&apos;s a bit imprecise, as it does
# involve rounding. The rounding also makes the table look dead wrong
# in some spots, because the difference between the second and third
# columns looks like it should be zero.
		col1 = str(round(col1, 11))[:13].ljust(13)
		col2 = str(round(col2, 11))[:13].ljust(13)
		print (col0, col1, col2, col3)</code></pre>
</blockquote>
<h5>Exercise 7.4</h5>
<blockquote>
<pre><code># What a horrid function this is! One must never trust user input
# enough to simply eval() it!
def eval_loop():
# The user might enter &quot;done&quot; right away without entering other
# expressions first. To account for that, we need a starting value for
# our return variable.
	val = None
	command = input(&quot;&gt;&gt;&gt; &quot;)
	while command != &quot;done&quot;:
		val = eval(command)
		print(val)
		command = input(&quot;&gt;&gt;&gt; &quot;)
	return val</code></pre>
</blockquote>
<h5>Exercise 7.5</h5>
<p>
	...
</p>
<p>
	This is a programming course, not an advanced mathematics course.
	I don&apos;t even understand the formula; there&apos;s no way I can implement it.
	That large symbol in the middle looks critical, but I don&apos;t even know what it means.
	I only learned about factorials this week, too; I had no idea what the exclamation point meant in maths before that.
</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		The main thing that I use functions for is code reuse, in both senses of the term.
		I write a function once, then import it into multiple scripts.
		I might even use a function multiple times from within the same script.
		Using functions from within multiple scripts requires that functions be defined in separate files than the main script, but it&apos;s well worth it.
	</p>
	<p>
		Parameters allow me to write less functions to cover more use cases and write functions for more types of situations.
		Often times, one function can cover more cases if its inner workings can be adjusted slightly.
		Parameters are great for this, as they can be used to alter one of the function&apos;s local variables, changing the output.
		Additionally, parameters are great for specifying what data a function should operate on.
		A function that provides identical output every time is almost useless; you might as well replace the function call with its output.
		Parameters provide a clean way to feed your function the data you want it to process.
		Almost every function that I write has parameters for this very reason.
	</p>
	<p>
		Return values are often vital, especially when trying to generalize your code.
		Functions that process data shouldn&apos;t do anything with the result, as you might need something different done with the result next time.
		Perhaps one time, you want to pass the result to the <code>print()</code> function, but in a different script or different part of the same script, you want write the result to a database.
		Instead of doing either of these, the function should return the result and allow other parts of the code to decide what to do with the return value.
		This provides a level of versatility that increases our ability to reuse functions instead of rewriting them.
	</p>
	<p>
		Some people also argue that using functions helps make code self-documenting.
		You can name a piece of code, it can be read and understood, then you can later use it in a concise manner in your main script without a human reader having to go through the steps of what each statement of the function does.
		Functions can also be used as placeholders.
		You can write up your main script, calling functions that don&apos;t exist yet from within it.
		Once finished, you can figure out how to implement those parts you haven&apos;t written yet, and write them as the missing functions.
	</p>
</blockquote>
<blockquote>
	<p>
		I don&apos;t think functions help hide information in programs, they just move the information elsewhere.
		It&apos;s helpful for making the program more readable, but the information is all still there and unhidden.
		Functions do help us not repeat ourselves while still being able to use the same algorithm repeatedly though.
	</p>
</blockquote>
<blockquote>
	<p>
		Debugging can be so much easier when using user-defined functions much of the time.
		When I was writing a Web spider at one point, I found that <abbr title="Uniform Resource Identifier">URI</abbr>s weren&apos;t being handled correctly, and it was crashing my spider.
		I tracked the issue back to my own function, which blindly depended on a built-in function to do some of the parsing.
		As it turned out, the built-in function was broken.
		I ended up having to write a suite of functions for parsing <abbr title="Uniform Resource Identifier">URI</abbr>s correctly myself.
		All I had to do was replace the call to the bad function within my own function with my new, good function, and everything worked.
		I didn&apos;t need to find every instance of the bad function getting called, as it&apos;d been only used within my own function as part of a subroutine!
	</p>
	<p>
		I later replaced that whole suite of functions with a class, but in either case, fixing the subroutine fixes the entire script.
		You don&apos;t have to find and fix the same exact bug five times in your code.
	</p>
</blockquote>
<blockquote>
	<p>
		You make an excellent point about readability, maintainability, debugability, and scalability.
		Without functions, code can get pretty messy and unmanageable.
	</p>
	<p>
		Using return values from one function from within another function can be useful much of the time as well.
		Two (or more) functions might have sections that can be generalized into a third function to avoid redundancy in the code, the the return value of this third function will usually be useful to the first two functions.
	</p>
</blockquote>
<h2 id="Unit7">Unit 7</h2>
<p>
	The learning guide has a couple mistakes in it.
	First, it says we learned about lists in <a href="https://y.st./en/coursework/CS1101/#Unit5">Unit 5</a>.
	I&apos;m almost certain we didn&apos;t cover lists until <strong>*this*</strong> unit, <a href="https://y.st./en/coursework/CS1101/#Unit7">Unit 7</a>.
	Second, it says that lists can only contain elements of the same type.
	However, just as the textbook says, lists can contain a mix of data types.
</p>
<p>
	The reading assignment said that Python doesn&apos;t handle letter comparison the same way people do.
	That&apos;s a bit misleading.
	Python doesn&apos;t handle letter comparison the same way <strong>*all*</strong> people do, but as different people handle letter comparisons differently, Python compares letters exactly like <strong>*some*</strong> people do.
	The simple fact is, upper-case wye (&quot;Y&quot;) and lower-case wye (&quot;y&quot;) are not the same letter.
	We can show this pretty easily with proper nouns and sentence beginnings.
	For example, if your name is &quot;Sam&quot;, is &quot;sam&quot; a proper spelling of your name?
	No.
	It must be a misspelling, then; the wrong letter was used.
	The name must begin in an upper-case letter; upper-case and lower-case letters are <strong>*not*</strong> the same letters!
</p>
<p>
	Personally, I don&apos;t care what order is used for alphabetizing as long as it&apos;s easy to understand and is consistent.
	For example, maybe you prefer to alphabetize like this:
</p>
<ul>
	<li>
		A
	</li>
	<li>
		a
	</li>
	<li>
		B
	</li>
	<li>
		b
	</li>
	<li>
		C
	</li>
	<li>
		c
	</li>
</ul>
<p>
	Or perhaps, you prefer to alphabetize like this:
</p>
<ul>
	<li>
		A
	</li>
	<li>
		B
	</li>
	<li>
		C
	</li>
	<li>
		a
	</li>
	<li>
		b
	</li>
	<li>
		c
	</li>
</ul>
<p>
	However, I don&apos;t think that this should in any way be considered valid:
</p>
<ul>
	<li>
		Aa
	</li>
	<li>
		ab
	</li>
	<li>
		Ac
	</li>
</ul>
<p>
	The problem is that it treats &quot;A&quot; and &quot;a&quot; as the same letter, even though they&apos;re not.
	On principle, this is wrong.
	However, it can be bad in practice too.
	For example, lets say you need to keep things in a consistent and predictable order.
	Several people will be handling the alphabetized items, and they all need to be following the same rules for sorting as to keep things in order.
	Let&apos;s say you have some children&apos;s books titled &quot;Happy Banana&quot; and &quot;Happy banana&quot;.
	How do you sort &quot;Banana&quot; and &quot;banana&quot;?
	One way is to simply say the order doesn&apos;t matter.
	This violates the need to keep a consistent order though.
	The other way is to add needlessly-complex sorting rules.
	For example, after a case-insensitive sorting, if two items belong in the same place, you&apos;d sort them case sensitively next or something.
	It removes the ambiguity, but it makes sorting more painful than it needs to be.
</p>
<p>
	I had to change desktop interfaces just to escape a stupid sorting problem like this.
	It wasn&apos;t exactly a case sensitivity issue, but file names weren&apos;t being sorted properly and it make it difficult to find files.
	Forcing bizarre sorting algorithms on the user (for example, case-insensitive name comparisons) isn&apos;t a nice thing to do.
	Providing it as an option if fine, and setting it as the default option might even be considered by many to be acceptable or even positive, but at least provide a way to opt out.
	I had several numerically-named files that I&apos;d downloaded a while back.
	My file manager (which was heavily built into the desktop) combined all numeric characters, then sorted by which number was greater.
	I knew the first few digits of the file names, but not the whole number.
	Due to the bizarre sorting, I couldn&apos;t find my files!
	There wasn&apos;t a way to get the file manager to stop treating digit characters as magically special either, and as I couldn&apos;t replace only the file manager because it was too heavily integrated into the desktop, I had to replace the whole desktop.
	Please.
	If you&apos;re building user-facing software that sorts something, files or otherwise, don&apos;t force complex sorting algorithms on the user!
	If you want to implement such algorithms, at least provide a basic <abbr title="American Standard Code for Information Interchange">ASCII</abbr>/Unicode sort as an option for users to switch to if needed!
	This is an extreme example for sure, but even a case-insensitive sort can be mildly irritating to those of use that prefer to sort things more consistently and more reasonably.
</p>
<p>
	Lists in Python have very different properties than I&apos;m used to in <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>.
	In <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>, array elements have both a key and a value.
	The key is used to indicate which element you want to access.
	However, Python lists don&apos;t have keys; they have indices.
	This is an important distinction.
	In <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>, if you have an array of five items and you delete the item with key <code>2</code>, you now have an array with keys <code>0</code>, <code>1</code>, <code>3</code>, and <code>4</code>.
	The keys don&apos;t change just because there&apos;s a gap.
	However, Python doesn&apos;t use keys for lists, and instead, elements are accessed via their indices.
	This causes a couple of interesting things to happen when working with lists.
	First, if you delete list elements, the other elements closer to the end appear to &quot;slide over&quot;.
	In the example above of deleting element <code>2</code>, in Python, element <code>3</code> would become the new element <code>2</code> and element <code>4</code> would become the new element <code>3</code>.
	There&apos;d no longer be an element <code>4</code>, but there&apos;s still be an element <code>2</code>.
	Second, negative indices can be used to access items based on position from the end of the list instead of from the beginning.
	Because <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> uses keys instead of indices, it doesn&apos;t work that way in <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>.
	An key can be negative if you chose it to be, but that negative key won&apos;t be the same as a different positive key.
</p>
<p>
	This week&apos;s programming assignment involves writing code to sort the fruit names in a file we&apos;re given.
	The line endings in this file are bizarre though. Instead of being <code>\n</code> like they should be or <code>\r\n</code> like Windows would format them, some of them are <code>\r\n\n</code> and some are <code>\n\r\n</code>, aside from the end on the final line, which is the basic <code>\n</code>.
	Who wrote this file and what kind of bizarre setup did their computer have?
	Why aren&apos;t their line endings consistent?
	We haven&apos;t covered the cleaning up of messy data such as this, so I&apos;m curious to see how the other students deal with the situation.
	As for me, I&apos;ve coded my <a href="https://y.st./en/coursework/CS1101/sort_fruits.py.xhtml">script</a> to convert the line endings to <code>\n</code>, as they should have been to start with.
	After getting the script working in Python3, I tested again in Python2.
	There were no detectable differences in how the script ran, so no extra effort was needed to make the script compatible with both versions of the interpreter this week.
</p>
<p>
	In addition to the textbook chapters assigned for us to read, some optional videos and supplementary reading material was provided:
</p>
<ul>
	<li>
		<a href="https://www.youtube.com/watch?v=9LgyKiq_hU0">For Loops in Python</a>
	</li>
	<li>
		<a href="https://www.youtube.com/watch?v=D0Nb2Fs3Q8c">While Loops in Python</a>
	</li>
	<li>
		<a href="https://www.youtube.com/watch?v=JA4neapsdqQ">Unit7</a>
	</li>
	<li>
		<a href="https://www.youtube.com/watch?v=zEyEC34MY1A">Python Lists</a>
	</li>
	<li>
		<a href="http://effbot.org/zone/python-list.htm">An Introduction to Python Lists</a>
	</li>
	<li>
		<a href="http://www.dreamincode.net/forums/topic/198139-reading-and-writing-to-a-txt-file-in-python/">Attention Required! | Cloudflare</a>
	</li>
</ul>
<p>
	Unfortunately, due to poor use of one of my two days off this week, I didn&apos;t have time to go over the supplementary material.
	I did watch the Unit7 video though, and it seems our professor gives us the solution to the assignment this week!
	Or rather, <strong>*a*</strong> solution.
	My submission for the week is structured differently, but it does mostly the same thing.
	I also skipped the turtle exercises from Unit 5.
	I was planning to come back to them, but there&apos;s simply no time to decipher how turtles work right now.
	Other than that, I finished catching up with the exercises from past units.
</p>
<p>
	Lastly for the week, I took the ungraded quiz and graded the assignment submissions from last week.
	The first submission I graded was programmed to continue taking input as long as the user wanted to compare numbers.
	After making a comparison, the script asked the user if another comparison was wanted, then looped back to the beginning if the user said yes.
	Why didn&apos;t I think of that!
	I hard-coded my solution to make three comparisons, as three comparisons were needed for the assignment.
	Now I feel foolish.
	The second submission I graded was structured in what I thought was a needlessly-complex way, but it too looped for as long as the user wanted it to!
	Am I just the dunce of the class, unable to think to implement such a simple concept?
	As for the third and final submission I graded, not only was the looping behavior present in the code, it was even present in the flowchart, unlike in the previous two submissions!
	Yup.
	It seems that last week, I was the dunce.
	I don&apos;t think this week&apos;s assignment has the room for creativity that last week&apos;s did though, so I shouldn&apos;t do poorly this time.
	I implemented the line ending normalization, which really, I think&apos;s the only thing the assignment didn&apos;t ask for that fits the goal of the code.
</p>
<p>
	My final thought for the week is that I can&apos;t believe I didn&apos;t think to implement a basic, continuous loop.
	I used a loop that was predetermined to execute thrice instead.
	I knew at the time that it was a bad implementation in general, but I thought that given the exercise, it was the best implementation to accomplish the goal.
	I need to generalize better.
	While I need to meet the goals of the assignment, I also need to write code using paradigms consistent with user-facing code.
	I mean, it&apos;s obvious that most of the code we write for this class is not to be run later.
	It&apos;s basic exercises meant to illustrate concepts, so it&apos;s not exactly code you mass distribute and hope other people take interest in.
	However, that doesn&apos;t mean that it shouldn&apos;t meet with certain minimum-quality requirements.
	After all, this is practice; practicing good quality helps one create good quality once it actually matters, too.
	I approach these assignments with fun as one of the goals, but I still take them very seriously.
</p>
<h3>Exercises</h3>
<h4>From <a href="https://y.st./en/coursework/CS1101/#Unit4">Unit 4</a></h4>
<h5>Exercise 3.3</h5>
<blockquote>
<pre><code>def right_justify(string):
# If right-justification puts the end of the text at column 70, there
# must be 72 columns total: column 0 is at the beginning and column 71
# is a line feed.
	indent = 71 - len(string)
# We don&apos;t want the script to crash, so let&apos;s make sure we don&apos;t try to
# multiply the space character by a negative number.
	if indent &lt; 0:
		indent = 0
	print(&quot; &quot; * indent + string)</code></pre>
</blockquote>
<h5>Exercise 3.4</h5>
<blockquote>
<pre><code>def do_twice(f, arg):
	f(arg)
	f(arg)

def print_twice(arg):
	print(arg)
	print(arg)

def do_four(f, arg):
	do_twice(f, arg)
	do_twice(f, arg)</code></pre>
</blockquote>
<h5>Exercise 3.5</h5>
<blockquote>
<pre><code>def grid(size):
	if size &lt; 0:
		size = 0
	for _ in range(size):
		for _ in range(size):
			print(&quot;+ - - - - &quot;, end=&quot;&quot;)
		print(&quot;+&quot;)
		for _ in range(4):
			for _ in range(size):
				print(&quot;|         &quot;, end=&quot;&quot;)
			print(&quot;|&quot;)
	for _ in range(size):
		print(&quot;+ - - - - &quot;, end=&quot;&quot;)
	print(&quot;+&quot;)</code></pre>
</blockquote>
<h4>From <a href="https://y.st./en/coursework/CS1101/#Unit5">Unit 5</a></h4>
<h5>Exercise 5.2</h5>
<blockquote>
<pre><code>def is_triangle(a, b, c):
	if a &gt; b + c or b &gt; a + c or c &gt; a + b:
		print(&quot;No&quot;)
	else:
		print(&quot;Yes&quot;)

def prompt_is_triangle():
	a = int(input(&quot;Please enter a value for A.\n&gt;&gt;&gt; &quot;))
	b = int(input(&quot;Please enter a value for B.\n&gt;&gt;&gt; &quot;))
	c = int(input(&quot;Please enter a value for C.\n&gt;&gt;&gt; &quot;))
	is_triangle(a, b, c)</code></pre>
</blockquote>
<h4>From <a href="https://y.st./en/coursework/CS1101/#Unit5">Unit 7</a></h4>
<h5>Exercise 8.1</h5>
<blockquote>
<pre><code>def function(string):
	index = len(string)
	while index:
		index -= 1
		print(string[index])</code></pre>
</blockquote>
<h5>Exercise 8.2</h5>
<blockquote>
<pre><code>prefixes = &quot;JKLMNOPQ&quot;
suffix = &quot;ack&quot;
for letter in prefixes:
	if letter == &quot;O&quot; or letter == &quot;Q&quot;:
		letter += &quot;u&quot;
	print(letter + suffix)</code></pre>
</blockquote>
<h5>Exercise 8.3</h5>
<p>
	<code>[:]</code> can simply be omitted from <code>fruit[:]</code>, as it refers to the whole string; the same thing <code>fruit</code> alone refers to.
</p>
<h5>Exercise 8.4</h5>
<blockquote>
<pre><code>def find(word, letter, index):
	while index &lt; len(word):
		if word[index] == letter:
			return index
		index = index + 1
	return -1</code></pre>
</blockquote>
<h5>Exercise 8.5</h5>
<blockquote>
<pre><code>def count(word, search):
	count = 0
	for letter in word:
		if letter == search:
			count = count + 1
	print(count)</code></pre>
</blockquote>
<h5>Exercise 8.6</h5>
<blockquote>
<pre><code>def count(word, search):
	count = 0
	index = find(word, search, 0)
	while index != -1:
		count += 1
		index = find(word, search, index+1)
	print(count)</code></pre>
</blockquote>
<h5>Exercise 8.7</h5>
<blockquote>
	<p>
		<code>&quot;banana&quot;.count(&quot;a&quot;)</code>
	</p>
</blockquote>
<h5>Exercise 8.8</h5>
<blockquote>
<pre><code>def is_reverse(word1, word2):
	if len(word1) != len(word2):
		return False
	i = 0
	j = len(word2) - 1
	while j &gt; -1:
		print(i, j)
		if word1[i] != word2[j]:
			return False
		i = i+1
		j = j-1
	return True</code></pre>
</blockquote>
<h5>Exercise 8.9</h5>
<blockquote>
<pre><code>def is_palindrome(string):
	return string == string[::-1]</code></pre>
</blockquote>
<h5>Exercise 8.11</h5>
<p>
	The first function tells only whether the first character in the string is lower-case.
</p>
<p>
	The second function returns strings, not boolean values.
</p>
<p>
	The third function only tells whether the final character in the string is lower-case.
	As a bonus, this function also throws an exception if the argument provided to it is the empty string.
</p>
<p>
	I think the fourth function might actually work as intended.
</p>
<p>
	The fifth function tells whether <strong>*all*</strong> the letters in the string are lower-case.
</p>
<h5>Exercise 8.12</h5>
<blockquote>
<pre><code>def rotate_word(string, rot):
	A = ord(&quot;A&quot;)
	Z = ord(&quot;Z&quot;)
	a = ord(&quot;a&quot;)
	z = ord(&quot;z&quot;)
	return_string = &apos;&apos;
	for char in string:
		integer = ord(char)
		if integer &gt;= A and integer &lt;= Z:
# It&apos;s easy to say that if the resulting addition from applying the
# rotation to the letter is too big, to simply subtract twenty-six.
# However, that doesn&apos;t work in practice because of two corner cases.
# First, the easiest way to decode the rotation is to rotate by a
# negative version of the same amount used to encode. Using a basic
# subtraction, some characters might dip below &quot;A&quot; and become
# non-letter characters. That&apos;s not what we want. We *could* account
# for that by checking the lower bounds as well, but there&apos;s no point
# because of the second corner case. Fixing the second corner case
# fixes the first without further effort.
#
# The second corner case is more interesting: integers with a high
# absolute value. What happens if you rotate by, say, fifty or negative
# fifty? If we check the upper and lower bounds after applying the
# rotation, then simply add or subtract once to loop around, we&apos;ll
# still be out of bounds and our function will still provide the wrong
# return value. There are two ways to fix this. The first is to put the
# check in a loop and keep looping until we have a valid character
# value. That seems somehow excessive though. The second option is to
# use modulo division. Modulo division basically loops around for us,
# then just provides us with the remainder. That sounds exactly like
# what we want, aside from that we want an offset. We can simulate the
# offset through subtracting the lower-bound letter.
			offset = A
		elif integer &gt;= a and integer &lt;= z:
			offset = a
		else:
			return_string += char
			continue
		integer -= offset
		integer += rot
		integer %= 26
		return_string += chr(integer+offset)
	return return_string</code></pre>
</blockquote>
<h5>Exercise 10.1</h5>
<blockquote>
<pre><code>def cumulative_sum(list):
	r = []
	sum = 0
	for i in list:
		sum += i
		r.append(sum)
	return r</code></pre>
</blockquote>
<h5>Exercise 10.2</h5>
<blockquote>
<pre><code>def chop(list):
	del list[0]
	del list[-1]

def middle(list):
	return list[1:-1]</code></pre>
</blockquote>
<h5>10.3</h5>
<blockquote>
<pre><code>def is_sorted(list):
	for i in range(len(list)-1):
		if list[i] &gt; list[i+1]:
			return False
	return True</code></pre>
</blockquote>
<h5>10.4</h5>
<blockquote>
<pre><code>def is_anagram(x, y):
	x = list(x)
	x.sort()
	x = &apos;&apos;.join(x)
	y = list(y)
	y.sort()
	y = &apos;&apos;.join(y)
	return x == y</code></pre>
</blockquote>
<h5>Exercise 10.5</h5>
<blockquote>
<pre><code>def has_duplicates(list):
	test = list[:]
	test.sort()
	for i in range(len(test)-1):
		if test[i] == test[i+1]:
			return True
	return False</code></pre>
</blockquote>
<h5>Exercise 10.6</h5>
<blockquote>
<pre><code>def remove_duplicates(list):
	r = []
	for i in list:
		if i not in r:
			r.append(i)
	return r</code></pre>
</blockquote>
<h5>Exercise 10.7</h5>
<blockquote>
<pre><code>def function_0():
	file = open(&quot;words.txt&quot;, &quot;r&quot;)
	list = file.read().split()
	file.close()
# We should simply return the list, but the exercise wants us to build
# the return list another way.
	t = []
	for x in list:
		t.append(x)
	return t

def function_0():
	file = open(&quot;words.txt&quot;, &quot;r&quot;)
	list = file.read().split()
	file.close()
# We should simply return the list, but the exercise wants us to build
# the return list another way.
	t = []
	for x in list:
		t = t + [x]
	return t</code></pre>
</blockquote>
<h5>Exercise 10.9</h5>
<blockquote>
<pre><code>def find_reverse_pairs(list):
	r = []
	for i in list:
		if i[::-1] in list:
			test0 = (i, i[::-1])
			test1 = (i[::-1], i)
			if test0 not in r and test1 not in r:
				r.append(test0)
	return r</code></pre>
</blockquote>
<h5>Exercise 10.10</h5>
<blockquote>
<p>
	If I understand the instructions correctly, I&apos;d need a list of all valid words in the language to complete this exercise.
	That seems like overkill for a basic exercise, so I&apos;m probably not understanding the instructions.
</p>
</blockquote>
<h5>Exercise 12.1</h5>
<blockquote>
<pre><code>def sumall(*args):
	sum = 0
	for i in args:
		sum += i
	return sum</code></pre>
</blockquote>
<h5>Exercise 12.2</h5>
<blockquote>
<pre><code>import random

def sort_by_length(words):
	t = []
	for word in words:
		t.append((len(word), random.random(), word))
	t.sort(reverse=True)
	res = []
	for length, rand, word in t:
		res.append(word)
	return res</code></pre>
</blockquote>
<h5>Exercise 12.3</h5>
<blockquote>
<pre><code>def most_frequent(string):
	count = {}
	for char in string:
		if char not in count:
			count[char] = 0
		count[char] += 1
	count_list = []
	for char in count:
		count_list.append((count[char], char))
	count_list.sort()
	count_list.reverse()
	for tuple in count_list:
		print(tuple[1])</code></pre>
</blockquote>
<h3>Exercise 12.4</h3>
<blockquote>
<pre><code>def anagrams(list):
	dict = {}
	for word in list:
		key = &quot;&quot;.join(sorted(word))
		if key not in dict:
			dict[key] = []
		dict[key].append(word)
	dict_list = []
	for set in dict:
		dict_list.append((len(dict[set]), dict[set]))
	dict_list.sort()
	dict_list.reverse()
	for set in dict_list:
		print(set[1])</code></pre>
</blockquote>
<p>
	The second part of this exercise seems to require processing an entire dictionary.
	That seems like overkill for an exercise.
</p>
<h5>Exercise 12.5</h5>
<p>
	This exercise seems to require a file that wasn&apos;t included in the textbook.
</p>
<h3>Discussion board drafts</h3>
<blockquote>
	<p>
		The main advantage of test-driven development, in my opinion, is the testing suite you have to build to make it work.
		Whenever there&apos;s an accidental regression, you&apos;ll notice it when you rerun your tests (which should be before your next release).
		You should test every case you can think of that might break your code, as well as some normal use cases.
		Once you&apos;ve developed code to test your main code, you simply keep your test code on hand in a separate repository.
		If you update your code and it ever fails your tests, you know one of two things has happened.
		First and most likely, you&apos;ve broken something in your code.
		The testing suite has picked up on the presence of the error, so now all you&apos;ve got to do is find and correct it.
		The second option is that you&apos;ve intentionally altered the output of your code, and the testing suite&apos;s out of date.
		In this case, simply update the testing suite with code that properly handles the new output of your main code.
		Additionally, the testing suite can be updated as bug reports are filed or bugs are found by you.
		Set up the testing suite to test that particular case, then after you fix your code, your code will pass.
		This&apos;ll help prevent regression and reintroduction of this bug.
	</p>
	<p>
		The  only disadvantage I can find in test-driven development is the time and effort it takes to build the test suite.
		It&apos;s so much easier to test small parts as you go and debug that way than it is to build actual tests for the output.
		While I fully intend to keep my test suite up to date with all new functionality I add to my code, the truth is that I fall short of that.
		Much of my code still doesn&apos;t have repeatable test cases built for it yet, and likely never will.
		My time is finite, and I barely have time to work on my code at all, let alone build test code that&apos;ll never be deployed outside my own laptop.
	</p>
</blockquote>
<blockquote>
	<p>
		Oops, I explained the advantages and disadvantages, but I forgot to actually specify what test-driven development is!
		Test-driven development is a development process that involves building a testing suite alongside the main project you&apos;re developing.
		As you go, you update the testing suite to account for various things the project code might do, alerting you to when it does something incorrectly.
		Even after you&apos;re theoretically done with the testing code, you&apos;re never actually done with it.
		You keep it to run alongside your new tests, so if old functionality breaks, you get alerted to that as well.
	</p>
</blockquote>
<blockquote>
	<p>
		Test-writing can be quite time-consuming for sure.
		When you write tests before you write your code, you might also run into the fact that you don&apos;t know what your code&apos;s output will be until you write it.
		I often plan my code to behave one way, but find a better behavior part-way through development.
		In cases such as those, tests written beforehand will fail.
		To be clear, I don&apos;t just mean that the internals will work differently.
		You may find you need different input to your code to make it work, or you might think of more useful output or a more useful format for the output.
	</p>
</blockquote>
<blockquote>
	<p>
		I like the wording you used on that.
		The test code chechs to see that actual output matches expected output.
		If it doesn&apos;t, an error&apos;s been introduced somewhere; the error must be found and corrected.
	</p>
</blockquote>
<blockquote>
	<p>
		Small cycles can indeed be helpful.
		Taking on too much at once has the possibility of introducing many errors at once.
		With several errors, a longer debugging session would be needed, and the errors would be potentially more difficult to find.
	</p>
</blockquote>
<h4>Exercise 11.7</h4>
<blockquote>
<pre><code>def has_duplicates(list):
	dict = {}
	for i in list:
		if i in dict:
			return True
		else:
			dict[i] = True
	return False</code></pre>
</blockquote>
<h2 id="Unit8">Unit 8</h2>
<p>
	The learning guide says that in Python, dictionaries are implemented as objects, so by working with them, we&apos;ll get a taste of object-oriented programming.
	Python dictionaries are objects - that&apos;s technically correct.
	WHat it fails to take into account though is that <strong>*everything*</strong> in Python is an object!
	Not literally everything; operators and such aren&apos;t objects.
	However, every variable contains and all nameable structures (for example, functions) are objects stored in variables.
	Even <code>None</code> and the boolean values are objects!
	We&apos;ve been working with objects the whole time, and dictionaries aren&apos;t much different than lists as far as how much they express that they&apos;re objects.
</p>
<p>
	The learning guide also says that Windows uses the backslash character as a path separator, which again, is technically correct.
	However, is says that it uses it <strong>*instead*</strong> of the forward slash.
	This is incorrect.
	Most reasonable systems use the forward slash character.
	However, Windows instead uses both the forward slash <strong>*and*</strong> the backslash as path separators.
	In fact, in Windows file paths, the two characters are interchangeable.
	Yeah.
	Windows is <strong>*that*</strong> messed up.
	In any case, what does this mean in practical terms?
	It means that one should <strong>*almost always*</strong> use the forward slash in file paths.
	By doing so, the path will (unless prefixed with a Windows drive letter) work on most operating systems without any negative consequences in Windows.
	Like the learning guide says too, the backslash is used as the escape character in Python and several other languages.
	Using the backslash in a string file path requires using a double backslash instead of a single backslash.
	Using forward slashes is just <strong>*easier*</strong>!
	I&apos;d never advocate ease over doing things right, but when ease lines up with doing things right like this, it makes it difficult to justify doing things the wrong way; there&apos;s simply no excuse for using backslashes in file paths in most cases.
</p>
<p>
	The first assignment submission I graded from last week was just awful.
	It didn&apos;t do <strong>*anything*</strong> the assignment told us to have it do!
	It didn&apos;t read an input file, didn&apos;t parse anything, and didn&apos;t write its output to an output file.
	Some people just can&apos;t follow simple directions.
	In fact, the syntax is bad for even what it does try to actually do, which is define an array statically in-file, so it doesn&apos;t even manage to do that.
	I tried running it in both Python2 and Python3 to be sure I was right about the strange-looking syntax, and sure enough, this thing doesn&apos;t even make it past the parsing stage.
	I think it might use ... C syntax?
	I&apos;m not sure, I don&apos;t know C yet.
	The second submission accounted for the strangeness of the line endings in the input file by ... providing a custom input file.
	Really?
	You can&apos;t account for bad input by replacing it with your own specially-crafted input by hand before your script even runs!
	The real kicker though is that the custom input file&apos;s bad too.
	As such, the output of the script is incorrect.
	The final submission used pseudocode to plan the script.
	This pseudocode was commented out too, which was interesting.
	While it wasn&apos;t included in the real script, it <strong>*could*</strong> have been because it&apos;d been commented out.
	Unfortunately, the way the script dealt with the bizarre line endings was to read the whole file into a variable, then use <code>.split()</code> to break the file into words.
	Judging by the provided output, this removed extra line ending characters.
	However, it also broke multi-word fruit names into separate fruit!
	So close to perfect, but not quite.
</p>
<p>
	Lastly for the week, I took the ungraded quiz.
	I did better than I thought I would, and actually got the history questions right.
</p>
<h3>Epilogue (Unit 9)</h3>
<p>
	I tried to complete the course evaluations, but it seems I was too late for that.
	This week&apos;s been very busy for me, so I though I&apos;d fill out the evaluations during the slower exam week.
	No such luck, they were due yesterday.
	That really suck, as I had an issue I really wanted to report.
	My professor also recommended retaking the ungraded quizzes before the exam, but those were still closed during Unit 8.
	I thought maybe they&apos;d open up again during Unit 9, but that didn&apos;t happen.
	Too bad, too, I was looking forward to going back any finally taking the <a href="https://y.st./en/coursework/CS1101/#Unit2">Unit 2</a> ungraded quiz I missed.
</p>
<p>
	Unit 9, the exam unit, came with its own ungraded quiz, so I took that before the final exam.
	The ungraded quiz was actually both longer and tougher than the actual exam.
	The actual exam didn&apos;t ask any history questions, so I should have scored pretty high on that.
</p>
<p>
	My final thoughts for the term are that I really hope my tuition issue gets cleared up in time for next term.
	I sent a cashier&apos;s cheque to University of the People for $200 <abbr title="United States Dollars">USD</abbr>, which would cover both courses I took this term.
	However, University of the People is now claiming I only paid for <strong>*one*</strong> of my two courses!
	If they don&apos;t fix this, they say they&apos;ll withdraw me from my courses for next term.
	I already hit a snag in the system last term, causing me to only have been able to register for one course that term, so I&apos;m a course behind schedule.
	I don&apos;t want to be another two courses behind!
	What do I do?
	This sucks.
	I&apos;ve written to the billing department, and am waiting for an email back from them as I type this.
	All I can do is hope they get it sorted out.
</p>
<h3>Exercises</h3>
<h4>Exercise 11.1</h4>
<p>
	Without knowing the format of the word file, this exercise is impossible to complete.
</p>
<h4></h4>
<blockquote>
<pre><code>def histogram(s):
	d = dict()
	for c in s:
		d[c] = d.get(c, 0) + 1
	return d</code></pre>
</blockquote>
<h4>Exercise 11.3</h4>
<blockquote>
<pre><code>def print_hist(h):
	for c in h.keys().sort():
		print(c, h[c])</code></pre>
</blockquote>
<h4>Exercise 11.4</h4>
<blockquote>
<pre><code>def reverse_lookup(d, v):
	list = []
	for k in d:
		if d[k] == v:
			list.append(k)
	list.sort()
	return list</code></pre>
</blockquote>
<h4>Exercise 11.5</h4>
<blockquote>
<pre><code>def invert_dict(d):
	inv = dict()
	for key in d:
		val = d[key]
		inv.setdefault(val, [])
		inv[val].append(key)
	return inv</code></pre>
</blockquote>
<h4>Exercise 11.7</h4>
<blockquote>
<pre><code>def has_duplicates(list):
	dict = {}
	for i in list:
		if i in dict:
			return True
		else:
			dict[i] = True
	return False</code></pre>
</blockquote>
<h4>Exercise 11.8</h4>
<blockquote>
<pre><code>def rotate_pairs(list):
	l = len(list)
	r = []
	for a in range(l):
		for b in range(a+1, l):
			if len(list[a]) == len(list[b]):
				a_ord = ord(list[a][0])
				b_ord = ord(list[b][0])
# Because we built rotate_word() to handle negative numbers as
# expected (see the solution to Exercise 8.12 above), we don&apos;t even
# need to know if the offset is positive or negative. We&apos;ll just pass
# it into the function without further preprocessing. It pays to do
# things the right way. You never know when you&apos;ll need to reuse your
# functions in an unexpected way, so making them handle all
# technically-valid input in the correct way will save you development
# time when you later reuse your code.
				offset = b_ord - a_ord
				test = rotate_word(list[a], offset)
				if test == list[b]:
					r.append((list[a], list[b]))
	return r</code></pre>
</blockquote>
<h4>Exercise 11.9</h4>
<p>
	<p>
		Language-processing?
		Seriously?
		That&apos;s a bit extensive for an entry-level course.
		Given my finite time, I&apos;m going to have to skip this.
	</p>
</p>
<h4>Exercise 14.1</h4>
<blockquote>
<pre><code>def walk(dir):
	list = []
	for name in os.listdir(dir):
		path = os.path.join(dir, name)
		if os.path.isfile(path):
			list.append(path)
		else:
			list += walk(path)
	return list</code></pre>
</blockquote>
<h4>Exercise 14.2</h4>
<blockquote>
<pre><code>def print_files(directory)
	unparsed = os.walk(directory)
	parsed = []
	i = 0

	for i in unparsed:
		dir = i[0]
		for file in i[2]:
			parsed.append(dir+&quot;/&quot;+file)

	parsed.sort()
	for i in parsed:
		print(i)</code></pre>
</blockquote>
<h4>Exercise 14.3</h4>
<blockquote>
<pre><code>import dbm
import pickle

def anagrams(list):
	dict = {}
	db = dbm.open(&quot;anagrams.db&quot;, &quot;c&quot;)
	for word in list:
		key = &quot;&quot;.join(sorted(word))
		if key not in dict:
			dict[key] = []
		dict[key].append(word)
	for set in dict:
		db[set] = pickle.dumps(dict[set])
	db.close()

def display_anagrams():
	db = dbm.open(&quot;anagrams.db&quot;, &quot;c&quot;)
	dict_list = []
	for set in db:
		dict_list.append((len(db[set]), picke.loads(db[set])))
	dict_list.sort()
	dict_list.reverse()
	for set in dict_list:
		print(set[1])
	db.close()</code></pre>
</blockquote>
<h4>Exercise 14.5</h4>
<p>
	This exercise requires network access.
	We haven&apos;t covered how to use SOCKS proxies in Python yet, and I never go online without tunneling my traffic through <abbr title="The Onion Router">Tor</abbr>.
	Normally, this is a choice I make out of principle.
	However, for the time being, I don&apos;t have home Internet access and my only way to get online is by using a proxy on my mobile device (I can&apos;t seem to get tethering to function).
	The only two on-device proxies I&apos;ve spotted both tunnel traffic through <abbr title="The Onion Router">Tor</abbr>, so <abbr title="The Onion Router">Tor</abbr>&apos;s my only gateway to the Internet for the time being.
</p>
<h4>Exercise 14.6</h4>
<blockquote>
<pre><code>import os

def list_files(directory, extension):
	index = 0 - len(extension)
	unparsed = os.walk(directory)
	parsed = []
	i = 0

	for i in unparsed:
		dir = i[0]
		for file in i[2]:
			if file[index:] == extension:
				parsed.append(dir+&quot;/&quot;+file)

	parsed.sort()
	return parsed

def find_duplicates(directory, extension):
	dupes = []
	dict = {}
	for file in files:
		c = os.popen(&quot;md5sum &quot;+file)
		md5sum = c.read().split()[0]
		c.close()
		if md5sum in dict:
			dupes.append((dict[md5sum], file))
		else:
			dict[md5sum] = file
	return dupes</code></pre>
</blockquote>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		A Python dictionary is basically an unordered list in which keys are used instead of numeric indices.
		Both dictionaries and lists provide something the other does not.
		Lists provide order, while dictionaries provide meaningful keys.
		My native language is <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>, so I find this separation to be very cumbersome.
		<abbr title="PHP: Hypertext Preprocessor">PHP</abbr> provides ordered key/value pairs.
		In <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>, you don&apos;t have to choose between meaningful indices and a dependable order, but in Python, you do.
	</p>
	<p>
		In Python, dictionaries can be used any time the order of your values doesn&apos;t matter, but the names of your keys does.
		For example, I used a dictionary in the solution to one of the exercises from the book this week:
	</p>
	<blockquote>
<pre><code>import os

def list_files(directory, extension):
	index = 0 - len(extension)
	unparsed = os.walk(directory)
	parsed = []
	i = 0

	for i in unparsed:
		dir = i[0]
		for file in i[2]:
			if file[index:] == extension:
				parsed.append(dir+&quot;/&quot;+file)

	parsed.sort()
	return parsed

def find_duplicates(directory, extension):
	dupes = []
	dict = {}
	for file in files:
		c = os.popen(&quot;md5sum &quot;+file)
		md5sum = c.read().split()[0]
		c.close()
		if md5sum in dict:
			dupes.append((dict[md5sum], file))
		else:
			dict[md5sum] = file
	return dupes</code></pre>
	</blockquote>
	<p>
		Here, the dictionary&apos;s keys matter, but the order of the keys doesn&apos;t.
		The keys are <abbr title="message digest 5">MD5</abbr> hashes of known files; we need to know if we&apos;ve seen a particular hash before, but we don&apos;t need to know at what point we say it.
		Instead, we only need to know <strong>*where*</strong> we saw it, so the values are the file names.
	</p>
</blockquote>
<blockquote>
	<p>
		I know, right?
		I&apos;m all in favor of properly indenting code, but I usually don&apos;t indent my scaffolding.
		If you don&apos;t indent it, it&apos;s easier to find and remove before releasing the code.
		However, that trick doesn&apos;t work in Python, as Python uses whitespace as a form of syntax, a very strange concept.
	</p>
</blockquote>
<blockquote>
	<p>
		I noticed you used <abbr title="Domain Name System">DNS</abbr> names (<code>com</code>, <code>com.uk</code>, <code>fr</code>, <code>ru</code>) to denote different countries, which is a good idea.
		However, <code>com</code> isn&apos;t really specific to the United States and the &quot;com.&quot; isn&apos;t really necessary in <code>com.uk</code> when just identifying the country.
		Every country actually has its own country code, which is the basis of <abbr title="country code top-level domain">ccTLD</abbr>s (those two-letter <abbr title="Top Level Domain">TLD</abbr>s such as <code>uk</code>, <code>fr</code>, and <code>ru</code>).
		All major countries (and some non-countries) have one.
		I think all the smaller countries have one too, but I can&apos;t swear to that.
		For example, the <abbr title="country code top-level domain">ccTLD</abbr> of the United States isn&apos;t <code>com</code>, but <code>us</code>.
		It&apos;s not as widely-used in the United States as it could be, but several United-States-based websites use it.
		<a href="https://www.replicant.us/"><code>https://www.replicant.us/</code></a> for example has a domain ending in <code>.us</code>.
	</p>
	<p>
		I&apos;m sorry that that got a bit off-topic, but <a href="https://y.st./en/URI_research/ccTLDs.xhtml"><abbr title="country code top-level domain">ccTLD</abbr>s are something I&apos;ve researched throughly in my search for a short domain name</a>.
	</p>
</blockquote>
<blockquote>
	<p>
		Any value can be used as a dictionary value, you&apos;re right.
		It&apos;s also worth noting though that only <strong>*immutable*</strong> values can be used as the keys.
		Immutable keys are mappable to mutable or immutable values.
		It&apos;s strange to me that Python dictionaries are unordered.
		In every other context I&apos;ve worth with, values have always had an order to them.
	</p>
</blockquote>
<blockquote>
	<p>
		You make a good point about speed.
		Checking the value of every list item isn&apos;t fast, so dictionaries are a good option for when many queries on the data will be needed, as long as those queries can be made using keys and not the values themselves.
		Key-value pairs are a powerful construct and Python dictionaries use them well.
	</p>
	<p>
		I like your example, too.
		It shows how dictionaries can even have dictionaries as their values.
	</p>
</blockquote>
		<hr/>
		<p>
			Copyright © 2017 Alex Yst;
			You may modify and/or redistribute this document under the terms of the <a rel="license" href="/license/gpl-3.0-standalone.xhtml"><abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
			If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
			My address is in the source comments near the top of this document.
			This license also applies to embedded content such as images.
			For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
		</p>
		<p>
			<abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
			This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fcoursework%2FCS1101%2F"><abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 5.1</a> specification and uses style sheets that conform to the <a href="http://jigsaw.w3.org./css-validator/validator?uri=https%3A%2F%2Fy.st.%2Fen%2Fcoursework%2FCS1101%2F"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
		</p>
	</body>
</html>

